[1883] | 1 | |
---|
| 2 | |
---|
[4597] | 3 | /* |
---|
[1883] | 4 | orxonox - the future of 3D-vertical-scrollers |
---|
| 5 | |
---|
| 6 | Copyright (C) 2004 orx |
---|
| 7 | |
---|
| 8 | This program is free software; you can redistribute it and/or modify |
---|
| 9 | it under the terms of the GNU General Public License as published by |
---|
| 10 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 11 | any later version. |
---|
| 12 | |
---|
[2036] | 13 | ### File Specific |
---|
| 14 | main-programmer: Patrick Boenzli |
---|
[4597] | 15 | co-programmer: |
---|
[1883] | 16 | */ |
---|
[5357] | 17 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY |
---|
[1883] | 18 | |
---|
| 19 | |
---|
| 20 | #include "environment.h" |
---|
[5143] | 21 | |
---|
| 22 | #include "resource_manager.h" |
---|
| 23 | |
---|
[2816] | 24 | #include "vector.h" |
---|
[3484] | 25 | #include "objModel.h" |
---|
[4682] | 26 | #include "obb_tree.h" |
---|
[5361] | 27 | #include "factory.h" |
---|
[1883] | 28 | |
---|
| 29 | using namespace std; |
---|
[5750] | 30 | CREATE_FACTORY(Environment, CL_ENVIRONMENT); |
---|
[1883] | 31 | |
---|
[4490] | 32 | /** |
---|
[4836] | 33 | * creates an environment |
---|
[4490] | 34 | */ |
---|
[2816] | 35 | Environment::Environment () : WorldEntity() |
---|
[1883] | 36 | { |
---|
[5361] | 37 | this->init(); |
---|
[5308] | 38 | this->loadModel("models/ships/bolido.obj"); |
---|
[4682] | 39 | |
---|
[5428] | 40 | if(this->obbTree == NULL) |
---|
| 41 | this->obbTree = new OBBTree(4, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount()); |
---|
[1883] | 42 | } |
---|
| 43 | |
---|
[5361] | 44 | /** |
---|
| 45 | * create an environment out of a XML-element |
---|
| 46 | * @param root the XML-element to load the Environment from |
---|
| 47 | */ |
---|
| 48 | Environment::Environment(const TiXmlElement* root) |
---|
| 49 | { |
---|
| 50 | this->init(); |
---|
| 51 | if (root != NULL) |
---|
| 52 | this->loadParams(root); |
---|
| 53 | } |
---|
[1883] | 54 | |
---|
[4490] | 55 | /** |
---|
[4836] | 56 | * deletes an environment |
---|
[4490] | 57 | */ |
---|
[4597] | 58 | Environment::~Environment () |
---|
[5047] | 59 | {} |
---|
[3566] | 60 | |
---|
[5361] | 61 | /** |
---|
| 62 | * initialize an Environment |
---|
| 63 | */ |
---|
| 64 | void Environment::init() |
---|
| 65 | { |
---|
| 66 | this->setClassID(CL_ENVIRONMENT, "Environment"); |
---|
| 67 | } |
---|
[1883] | 68 | |
---|
[4490] | 69 | /** |
---|
[5361] | 70 | * loads the Settings of an Environment from an XML-element. |
---|
| 71 | * @param root the XML-element to load the ELements properties from |
---|
| 72 | */ |
---|
| 73 | void Environment::loadParams(const TiXmlElement* root) |
---|
| 74 | { |
---|
| 75 | static_cast<WorldEntity*>(this)->loadParams(root); |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | /** |
---|
[4836] | 80 | * ticks the environment |
---|
| 81 | * @param time the time about which to tick |
---|
[4490] | 82 | */ |
---|
[2816] | 83 | void Environment::tick (float time) {} |
---|
[1883] | 84 | |
---|
[2816] | 85 | |
---|
[4490] | 86 | /** |
---|
[4836] | 87 | * draws the Environment |
---|
[4490] | 88 | */ |
---|
[5500] | 89 | void Environment::draw () const |
---|
[2816] | 90 | { |
---|
| 91 | glMatrixMode(GL_MODELVIEW); |
---|
[3526] | 92 | glPushMatrix(); |
---|
[2816] | 93 | float matrix[4][4]; |
---|
[4597] | 94 | |
---|
[3365] | 95 | glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z); |
---|
| 96 | //rotate |
---|
[3433] | 97 | this->getAbsDir().matrix (matrix); |
---|
[3365] | 98 | glMultMatrixf((float*)matrix); |
---|
[4597] | 99 | |
---|
[3365] | 100 | this->model->draw(); |
---|
[3526] | 101 | |
---|
| 102 | glPopMatrix(); |
---|
[2816] | 103 | } |
---|
| 104 | |
---|