/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: Benjamin Grauer co-programmer: ... */ #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY #include "model_entity.h" #include "util/loading/load_param.h" #include "util/loading/factory.h" #include "class_id_DEPRECATED.h" ObjectListDefinitionID(ModelEntity, CL_MODEL_ENTITY); CREATE_FACTORY(ModelEntity); /** * initializes a skybox from a XmlElement */ ModelEntity::ModelEntity(const TiXmlElement* root) { this->registerObject(this, ModelEntity::_objectList); this->toList(OM_ENVIRON); this->speed = NULL; this->momentum = NULL; this->setSynchronized(true); if (root != NULL) this->loadParams(root); } /** * default destructor */ ModelEntity::~ModelEntity() { if (this->speed != NULL) delete this->speed; if (this->momentum) delete this->momentum; } void ModelEntity::loadParams(const TiXmlElement* root) { WorldEntity::loadParams(root); LoadParam(root, "speed", this, ModelEntity, setSpeed); LoadParam(root, "momentum", this, ModelEntity, setMomentum); } void ModelEntity::setSpeed(float x, float y, float z) { if (this->speed == NULL) this->speed = new Vector; *this->speed = Vector(x,y,z); } void ModelEntity::setMomentum (float angle, float x, float y, float z) { Vector v(x,y,z); v.debug(); v.normalize(); v.debug(); if (this->momentum == NULL) this->momentum = new Quaternion; *this->momentum = Quaternion(angle, v); this->momentum->debug(); } void ModelEntity::tick(float dt) { if (this->speed != NULL) this->shiftCoor(*this->speed * dt); if (this->momentum != NULL) { this->shiftDir((*this->momentum * dt ).getNormalized()); //this->getAbsDir().debug(); } }