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