/* 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: Patrick Boenzli co-programmer: */ #include "environment.h" #include "stdincl.h" #include "world_entity.h" #include "vector.h" #include "objModel.h" using namespace std; CREATE_FACTORY(Environment); Environment::Environment () : WorldEntity() { this->model = new OBJModel("../data/models/fighter.obj"); } Environment::Environment ( TiXmlElement* root) { char* temp; const char* string = grabParameter( root, "name"); if( string == NULL) { PRINTF(1)("Environment is missing a proper 'name'\n"); string = "Unknown"; temp = new char[strlen(string + 2)]; strcpy( temp, string); this->setName( temp); } else { temp = new char[strlen(string + 2)]; strcpy( temp, string); this->setName( temp); } this->model = NULL; string = grabParameter( root, "model"); if( string != NULL) this->model = new OBJModel( string); else { PRINTF(1)("Environment is missing a proper 'model'\n"); this->model = new OBJModel( "../data/models/reaplow.obj"); } if( this->model == NULL) { PRINTF(1)("Environment model '%s' could not be loaded\n", string); } double buff[3]; string = grabParameter( root, "position"); if( string != NULL && sscanf( string, "%f,%f,%f", &(buff[0]), &(buff[1]), &(buff[2])) == 3) { Vector* es = new Vector( buff[0], buff[1], buff[2]); this->setAbsCoor(es); delete es; } else { PRINTF(1)("Environment is missing a proper 'position'\n"); Vector* es = new Vector(); this->setAbsCoor(es); delete es; } string = grabParameter( root, "orientation"); if( string != NULL && sscanf( string, "%f,%f,%f", &(buff[0]), &(buff[1]), &(buff[2])) == 3) { Quaternion* qs = new Quaternion( buff[0], buff[1], buff[2]); this->setAbsDir(qs); delete qs; } else { PRINTF(1)("Environment is missing a proper 'orientation'\n"); Quaternion* qs = new Quaternion (); this->setAbsDir(qs); delete qs; } } Environment::~Environment () { delete this->model; } void Environment::tick (float time) {} void Environment::hit (WorldEntity* weapon, Vector loc) {} void Environment::destroy () {} void Environment::collide (WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags) {} void Environment::draw () { glMatrixMode(GL_MODELVIEW); glLoadIdentity(); float matrix[4][4]; glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z); //rotate this->getAbsDir().matrix (matrix); glMultMatrixf((float*)matrix); this->model->draw(); }