Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/npc2.cc @ 5266

Last change on this file since 5266 was 5266, checked in by bensch, 19 years ago

orxonox/trunk: Shaders now work :)

File size: 2.2 KB
RevLine 
[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*/
17
18
[5266]19#include "npc2.h"
[5033]20#include "obb_tree.h"
[1853]21
[5266]22#include "shader.h"
[4984]23#include "state.h"
[5064]24#include "list.h"
[4984]25
[1858]26using namespace std;
[1853]27
[1858]28
[5266]29NPC2::NPC2()
[1931]30{
[4597]31  this->setClassID(CL_NPC, "NPC");
[4976]32
[5266]33  this->loadModelWithScale("models/ships/bolido.obj", 3);
34  this->shader = new Shader("toon.vert", "toon.frag");
35//  this->shader->activateShader();
36  //exit(-1);
[5059]37
[5266]38  this->obj = gluNewQuadric();
39
[5059]40  this->randomRotAxis = VECTOR_RAND(1);
[1931]41}
[1853]42
[5034]43
[5266]44NPC2::~NPC2 () {}
[1853]45
46
[5266]47void NPC2::collidesWith(WorldEntity* entity, const Vector& location)
[5029]48{
[5053]49  if (entity->isA(CL_PROJECTILE))
[5258]50  {
[5065]51    PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getName(), entity->getName(), location.x, location.y, location.z);
[5258]52    this->applyForce(Vector(0,0,0)-location*1000);
53  }
[5259]54  else if (entity->isA(CL_PLAYER))
55    this->applyForce(Vector(0,0,0)-location*100);
56  else
[5258]57  {
58    this->setVisibiliy(false);
59   State::getWorldEntityList()->remove(this);
60  }
[1931]61}
62
[5029]63
[5266]64/**
65 *  the entity is drawn onto the screen with this function
66 *
67 * This is a central function of an entity: call it to let the entity painted to the screen.
68 * Just override this function with whatever you want to be drawn.
69 */
70void NPC2::draw()
[4984]71{
[5266]72  glMatrixMode(GL_MODELVIEW);
73  glPushMatrix();
74  float matrix[4][4];
75
76  /* translate */
77  glTranslatef (this->getAbsCoor ().x,
78                this->getAbsCoor ().y,
79                this->getAbsCoor ().z);
80  /* rotate */
81  this->getAbsDir ().matrix (matrix);
82  glMultMatrixf((float*)matrix);
83
84  shader->activateShader();
85  gluSphere(this->obj, 3, 20, 20);
86  shader->deactivateShader();
87
88
89/*  if (this->model)
90    this->model->draw();*/
91  glPopMatrix();
92}
93
94
95void NPC2::tick(float dt)
96{
[5257]97//  Vector direction = (State::getCameraTarget()->getAbsCoor() - this->getAbsCoor());
[2036]98
[4986]99  //if (directin.len() < 100)
[5257]100//  this->shiftCoor(direction *dt * 5 * exp(-direction.len() / 30.0));
[5060]101  this->shiftDir(Quaternion(dt, this->randomRotAxis));
[4986]102
[4984]103}
104
105
[5033]106
Note: See TracBrowser for help on using the repository browser.