[4245] | 1 | |
---|
| 2 | |
---|
[4679] | 3 | /* |
---|
[4245] | 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 | |
---|
| 13 | ### File Specific |
---|
| 14 | main-programmer: Patrick Boenzli |
---|
[4679] | 15 | co-programmer: |
---|
[4245] | 16 | */ |
---|
[5357] | 17 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY |
---|
[4245] | 18 | |
---|
| 19 | |
---|
| 20 | #include "test_entity.h" |
---|
| 21 | #include "stdincl.h" |
---|
| 22 | #include "model.h" |
---|
| 23 | #include "md2Model.h" |
---|
[4682] | 24 | #include "obb_tree.h" |
---|
[5087] | 25 | #include "state.h" |
---|
| 26 | #include "list.h" |
---|
[4245] | 27 | |
---|
| 28 | using namespace std; |
---|
| 29 | |
---|
| 30 | |
---|
| 31 | |
---|
[4762] | 32 | TestEntity::TestEntity () |
---|
[4679] | 33 | { |
---|
[4320] | 34 | this->setClassID(CL_TEST_ENTITY, "TestEntity"); |
---|
[6142] | 35 | // TO SOME LIST!! |
---|
[4245] | 36 | |
---|
[5087] | 37 | this->md2Model = new MD2Model("models/droidika.md2", "models/droideka.pcx"); |
---|
[4714] | 38 | // this->md2Model = new MD2Model("models/tris.md2", "models/tris.pcx"); |
---|
[5087] | 39 | // this->md2Model = new MD2Model("models/goblin.md2", "maps/goblin.bmp"); |
---|
[4714] | 40 | |
---|
[5994] | 41 | /// FIXME |
---|
| 42 | // this->obbTree = new OBBTree(4, (sVec3D*)this->md2Model->data->pVertices, this->md2Model->data->numVertices); |
---|
| 43 | |
---|
[5087] | 44 | this->md2Model->setAnim(RUN); |
---|
[4276] | 45 | this->md2Model->debug(); |
---|
[4245] | 46 | } |
---|
| 47 | |
---|
| 48 | |
---|
[4679] | 49 | TestEntity::~TestEntity () |
---|
[4462] | 50 | { |
---|
| 51 | delete this->md2Model; |
---|
| 52 | } |
---|
[4245] | 53 | |
---|
| 54 | |
---|
[4488] | 55 | void TestEntity::setAnim(int animationIndex) |
---|
| 56 | { |
---|
| 57 | this->md2Model->setAnim(animationIndex); |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | |
---|
[4679] | 61 | void TestEntity::tick (float time) |
---|
[4245] | 62 | { |
---|
[4276] | 63 | this->md2Model->tick(time); |
---|
[4245] | 64 | } |
---|
| 65 | |
---|
| 66 | |
---|
[5087] | 67 | void TestEntity::collidesWith(WorldEntity* entity, const Vector& location) |
---|
| 68 | { |
---|
| 69 | if (entity->isA(CL_PROJECTILE)) |
---|
| 70 | { |
---|
| 71 | PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getName(), entity->getName(), location.x, location.y, location.z); |
---|
| 72 | this->setVisibiliy(false); |
---|
[6142] | 73 | this->toList(OM_DEAD); |
---|
[5087] | 74 | } |
---|
| 75 | } |
---|
| 76 | |
---|
[4245] | 77 | void TestEntity::destroy () {} |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | |
---|
| 81 | |
---|
[5500] | 82 | void TestEntity::draw () const |
---|
[4245] | 83 | { |
---|
| 84 | glMatrixMode(GL_MODELVIEW); |
---|
| 85 | glPushMatrix(); |
---|
| 86 | float matrix[4][4]; |
---|
[4679] | 87 | |
---|
| 88 | |
---|
[4245] | 89 | glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z); |
---|
| 90 | this->getAbsDir().matrix (matrix); |
---|
| 91 | glMultMatrixf((float*)matrix); |
---|
[4276] | 92 | this->md2Model->draw(); |
---|
[4245] | 93 | |
---|
[4679] | 94 | |
---|
[4245] | 95 | glPopMatrix(); |
---|
| 96 | } |
---|
| 97 | |
---|