[1853] | 1 | |
---|
| 2 | |
---|
[4597] | 3 | /* |
---|
[1853] | 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. |
---|
[1855] | 12 | |
---|
| 13 | ### File Specific: |
---|
| 14 | main-programmer: Patrick Boenzli |
---|
| 15 | co-programmer: |
---|
[1853] | 16 | */ |
---|
[5357] | 17 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY |
---|
[1853] | 18 | |
---|
| 19 | |
---|
[5682] | 20 | #include "npc_test.h" |
---|
[5033] | 21 | #include "obb_tree.h" |
---|
[1853] | 22 | |
---|
[5266] | 23 | #include "shader.h" |
---|
[4984] | 24 | #include "state.h" |
---|
[5427] | 25 | #include "stdlibincl.h" |
---|
[5511] | 26 | #include "debug.h" |
---|
[4984] | 27 | |
---|
[5511] | 28 | |
---|
[1858] | 29 | using namespace std; |
---|
[1853] | 30 | |
---|
[1858] | 31 | |
---|
[5266] | 32 | NPC2::NPC2() |
---|
[8724] | 33 | : NPC(NULL) |
---|
[1931] | 34 | { |
---|
[6004] | 35 | this->setClassID(CL_NPC_TEST2, "NPC2"); |
---|
[4976] | 36 | |
---|
[5621] | 37 | if ((float)rand()/RAND_MAX > .5f) |
---|
| 38 | this->loadModel("models/ships/bolido.obj", 3); |
---|
| 39 | else |
---|
| 40 | this->loadModel("models/ships/gobblin.obj", 3); |
---|
| 41 | |
---|
[5333] | 42 | this->shader = NULL; |
---|
| 43 | if (likely(Shader::checkShaderAbility())) |
---|
| 44 | this->shader = Shader::getShader("shaders/toon.vert", "shaders/toon.frag"); |
---|
[5059] | 45 | |
---|
[5266] | 46 | this->obj = gluNewQuadric(); |
---|
| 47 | |
---|
[5059] | 48 | this->randomRotAxis = VECTOR_RAND(1); |
---|
[1931] | 49 | } |
---|
[1853] | 50 | |
---|
[5034] | 51 | |
---|
[5267] | 52 | NPC2::~NPC2 () |
---|
| 53 | { |
---|
[5363] | 54 | if (this->shader) |
---|
| 55 | Shader::unload(this->shader); |
---|
[5313] | 56 | gluDeleteQuadric(this->obj); |
---|
[5267] | 57 | } |
---|
[1853] | 58 | |
---|
[5267] | 59 | |
---|
[1931] | 60 | |
---|
[5266] | 61 | /** |
---|
| 62 | * the entity is drawn onto the screen with this function |
---|
| 63 | * |
---|
| 64 | * This is a central function of an entity: call it to let the entity painted to the screen. |
---|
| 65 | * Just override this function with whatever you want to be drawn. |
---|
| 66 | */ |
---|
[5500] | 67 | void NPC2::draw() const |
---|
[4984] | 68 | { |
---|
[6004] | 69 | // glMatrixMode(GL_MODELVIEW); |
---|
| 70 | // glPushMatrix(); |
---|
| 71 | // float matrix[4][4]; |
---|
| 72 | // |
---|
| 73 | // /* translate */ |
---|
| 74 | // glTranslatef (this->getAbsCoor ().x, |
---|
| 75 | // this->getAbsCoor ().y, |
---|
| 76 | // this->getAbsCoor ().z); |
---|
| 77 | // /* rotate */ |
---|
| 78 | // this->getAbsDir ().matrix (matrix); |
---|
| 79 | // glMultMatrixf((float*)matrix); |
---|
| 80 | // |
---|
| 81 | // if (this->shader != NULL && this->shader != Shader::getActiveShader()) |
---|
| 82 | // shader->activateShader(); |
---|
| 83 | // gluSphere(this->obj, 3, 10, 10); |
---|
| 84 | // shader->deactivateShader(); |
---|
| 85 | // |
---|
| 86 | // |
---|
| 87 | // /* if (this->model) |
---|
| 88 | // this->model->draw();*/ |
---|
| 89 | // glPopMatrix(); |
---|
[5266] | 90 | } |
---|
| 91 | |
---|
| 92 | |
---|
| 93 | void NPC2::tick(float dt) |
---|
| 94 | { |
---|
[5257] | 95 | // Vector direction = (State::getCameraTarget()->getAbsCoor() - this->getAbsCoor()); |
---|
[2036] | 96 | |
---|
[4986] | 97 | //if (directin.len() < 100) |
---|
[5257] | 98 | // this->shiftCoor(direction *dt * 5 * exp(-direction.len() / 30.0)); |
---|
[5060] | 99 | this->shiftDir(Quaternion(dt, this->randomRotAxis)); |
---|
[4986] | 100 | |
---|
[4984] | 101 | } |
---|
| 102 | |
---|
| 103 | |
---|
[5033] | 104 | |
---|