Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/md2_loader/src/world_entities/test_entity.cc @ 4158

Last change on this file since 4158 was 4158, checked in by patrick, 19 years ago

orxonox/branches/md2_loader: now using the home brewed material class for the model - and it works just perfect! orxonox has a very powerfull material class./orxonox :D

File size: 1.9 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 "test_entity.h"
20#include "stdincl.h"
21#include "model.h"
22#include "md2Model.h"
23
24using namespace std;
25
26
27
28TestEntity::TestEntity () : WorldEntity()
29{
30  this->textureArray = new unsigned int[100];
31  memset(this->textureArray, 0, 100*sizeof(unsigned int));
32 
33  MD2Loader* md2loader = new MD2Loader();
34  this->model = new t3DModel;
35  this->md2Model = new MD2Model();
36
37  md2loader->importMD2(this->model, "../data/models/tris.md2", "../data/models/tris.pcx");
38
39  for(int i = 0; i < this->model->numOfMaterials; i++)
40    {
41      if( strlen(this->model->materialList[i].strFile) > 0)
42        {
43          Helper::createTexture(textureArray, this->model->materialList[i].strFile, i);
44        }
45      this->model->materialList[i].texureId = i;
46    }
47
48  this->material = new Material("Sky");
49  this->material->setDiffuseMap("../data/models/tris.pcx");
50  this->material->setIllum(3);
51  this->material->setAmbient(1.0, 1.0, 1.0);
52}
53
54
55TestEntity::~TestEntity () 
56{}
57
58
59void TestEntity::tick (float time) {}
60
61
62void TestEntity::hit (WorldEntity* weapon, Vector* loc) {}
63
64
65void TestEntity::destroy () {}
66
67
68void TestEntity::collide (WorldEntity* other,  Uint32 ownhitflags, Uint32 otherhitflags) {}
69
70
71void TestEntity::draw () 
72{
73  glMatrixMode(GL_MODELVIEW);
74  glPushMatrix();
75  float matrix[4][4];
76 
77  glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
78   this->getAbsDir().matrix (matrix);
79  glMultMatrixf((float*)matrix);
80 
81  //this->model->draw();
82  /* TESTGING TESTING TESTING */
83  this->material->select();
84  this->md2Model->draw(this->model);
85
86  glPopMatrix();
87}
88
Note: See TracBrowser for help on using the repository browser.