|
Last change
on this file since 5048 was
5046,
checked in by patrick, 20 years ago
|
|
orxonox/trunk: if a collision occures, the virtual WorldEntity::collidesWith(WorldEntity*, Vector) is called of both objects. the reaction to the collision has to be defined there. default reaction is still output into stdout console. There is now more information
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 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 | |
|---|
| 18 | |
|---|
| 19 | //#include "ai.h" |
|---|
| 20 | |
|---|
| 21 | #include "npc.h" |
|---|
| 22 | #include "obb_tree.h" |
|---|
| 23 | |
|---|
| 24 | #include "state.h" |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | using namespace std; |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | NPC::NPC() |
|---|
| 31 | { |
|---|
| 32 | this->setClassID(CL_NPC, "NPC"); |
|---|
| 33 | |
|---|
| 34 | this->loadModel("models/ships/bolido.obj"); |
|---|
| 35 | if(this->obbTree == NULL) |
|---|
| 36 | this->obbTree = new OBBTree(4, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount()); |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | NPC::~NPC () {} |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | void NPC::collidesWith(WorldEntity* entity, const Vector& location) |
|---|
| 44 | { |
|---|
| 45 | PRINTF(0)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z); |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | void NPC::tick(float dt) |
|---|
| 50 | { |
|---|
| 51 | Vector direction = (State::getCameraTarget()->getAbsCoor() - this->getAbsCoor()); |
|---|
| 52 | |
|---|
| 53 | //if (directin.len() < 100) |
|---|
| 54 | this->shiftCoor(direction *dt * 5 * exp(-direction.len()/30.0)); |
|---|
| 55 | |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.