Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/test_entity.cc @ 5789

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

orxonox/trunk: all the WorldEntities now have a const function to draw themselves

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