[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() |
---|
[1931] | 33 | { |
---|
[6004] | 34 | this->setClassID(CL_NPC_TEST2, "NPC2"); |
---|
[4976] | 35 | |
---|
[5621] | 36 | if ((float)rand()/RAND_MAX > .5f) |
---|
| 37 | this->loadModel("models/ships/bolido.obj", 3); |
---|
| 38 | else |
---|
| 39 | this->loadModel("models/ships/gobblin.obj", 3); |
---|
| 40 | |
---|
[5333] | 41 | this->shader = NULL; |
---|
| 42 | if (likely(Shader::checkShaderAbility())) |
---|
| 43 | this->shader = Shader::getShader("shaders/toon.vert", "shaders/toon.frag"); |
---|
[5059] | 44 | |
---|
[5266] | 45 | this->obj = gluNewQuadric(); |
---|
| 46 | |
---|
[5059] | 47 | this->randomRotAxis = VECTOR_RAND(1); |
---|
[1931] | 48 | } |
---|
[1853] | 49 | |
---|
[5034] | 50 | |
---|
[5267] | 51 | NPC2::~NPC2 () |
---|
| 52 | { |
---|
[5363] | 53 | if (this->shader) |
---|
| 54 | Shader::unload(this->shader); |
---|
[5313] | 55 | gluDeleteQuadric(this->obj); |
---|
[5267] | 56 | } |
---|
[1853] | 57 | |
---|
[5267] | 58 | |
---|
[1931] | 59 | |
---|
[5266] | 60 | /** |
---|
| 61 | * the entity is drawn onto the screen with this function |
---|
| 62 | * |
---|
| 63 | * This is a central function of an entity: call it to let the entity painted to the screen. |
---|
| 64 | * Just override this function with whatever you want to be drawn. |
---|
| 65 | */ |
---|
[5500] | 66 | void NPC2::draw() const |
---|
[4984] | 67 | { |
---|
[6004] | 68 | // glMatrixMode(GL_MODELVIEW); |
---|
| 69 | // glPushMatrix(); |
---|
| 70 | // float matrix[4][4]; |
---|
| 71 | // |
---|
| 72 | // /* translate */ |
---|
| 73 | // glTranslatef (this->getAbsCoor ().x, |
---|
| 74 | // this->getAbsCoor ().y, |
---|
| 75 | // this->getAbsCoor ().z); |
---|
| 76 | // /* rotate */ |
---|
| 77 | // this->getAbsDir ().matrix (matrix); |
---|
| 78 | // glMultMatrixf((float*)matrix); |
---|
| 79 | // |
---|
| 80 | // if (this->shader != NULL && this->shader != Shader::getActiveShader()) |
---|
| 81 | // shader->activateShader(); |
---|
| 82 | // gluSphere(this->obj, 3, 10, 10); |
---|
| 83 | // shader->deactivateShader(); |
---|
| 84 | // |
---|
| 85 | // |
---|
| 86 | // /* if (this->model) |
---|
| 87 | // this->model->draw();*/ |
---|
| 88 | // glPopMatrix(); |
---|
[5266] | 89 | } |
---|
| 90 | |
---|
| 91 | |
---|
| 92 | void NPC2::tick(float dt) |
---|
| 93 | { |
---|
[5257] | 94 | // Vector direction = (State::getCameraTarget()->getAbsCoor() - this->getAbsCoor()); |
---|
[2036] | 95 | |
---|
[4986] | 96 | //if (directin.len() < 100) |
---|
[5257] | 97 | // this->shiftCoor(direction *dt * 5 * exp(-direction.len() / 30.0)); |
---|
[5060] | 98 | this->shiftDir(Quaternion(dt, this->randomRotAxis)); |
---|
[4986] | 99 | |
---|
[4984] | 100 | } |
---|
| 101 | |
---|
| 102 | |
---|
[5033] | 103 | |
---|