| 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 "primitive.h" | 
|---|
| 20 | #include "stdincl.h" | 
|---|
| 21 | #include "world_entity.h" | 
|---|
| 22 | #include "vector.h" | 
|---|
| 23 | #include "objModel.h" | 
|---|
| 24 |  | 
|---|
| 25 | using namespace std; | 
|---|
| 26 |  | 
|---|
| 27 |  | 
|---|
| 28 |  | 
|---|
| 29 | /** | 
|---|
| 30 | \brief standard constructor | 
|---|
| 31 | */ | 
|---|
| 32 | Primitive::Primitive (PRIMITIVE_FORM form) : WorldEntity() | 
|---|
| 33 | { | 
|---|
| 34 | //this->model = new OBJModel("../data/models/fighter.obj"); | 
|---|
| 35 | //this->model = new OBJModel(""); | 
|---|
| 36 | this->object = gluNewQuadric(); | 
|---|
| 37 |  | 
|---|
| 38 | gluQuadricTexture(this->object, GL_TRUE); | 
|---|
| 39 |  | 
|---|
| 40 | this->material = new Material("Sphere"); | 
|---|
| 41 | this->material->setDiffuseMap("../data/pictures/load_screen.jpg"); | 
|---|
| 42 | this->material->setIllum(3); | 
|---|
| 43 | this->material->setSpecular(1, 1, 1); | 
|---|
| 44 | } | 
|---|
| 45 |  | 
|---|
| 46 |  | 
|---|
| 47 | /** | 
|---|
| 48 | \brief standard deconstructor | 
|---|
| 49 | */ | 
|---|
| 50 | Primitive::~Primitive () | 
|---|
| 51 | { | 
|---|
| 52 | delete this->material; | 
|---|
| 53 | free(this->object); | 
|---|
| 54 | } | 
|---|
| 55 |  | 
|---|
| 56 | /** | 
|---|
| 57 | \brief called, when the object gets hit | 
|---|
| 58 | \param other object, that hits it | 
|---|
| 59 | \param location of impact | 
|---|
| 60 | */ | 
|---|
| 61 | void Primitive::hit (WorldEntity* weapon, Vector* loc) {} | 
|---|
| 62 |  | 
|---|
| 63 |  | 
|---|
| 64 | /** | 
|---|
| 65 | \brief object collides | 
|---|
| 66 | */ | 
|---|
| 67 | void Primitive::collide (WorldEntity* other,  Uint32 ownhitflags, Uint32 otherhitflags) {} | 
|---|
| 68 |  | 
|---|
| 69 |  | 
|---|
| 70 | /** | 
|---|
| 71 | \brief tick singal put everything here, that is timedependent | 
|---|
| 72 | \param time in sec | 
|---|
| 73 | */ | 
|---|
| 74 | void Primitive::tick (float time) | 
|---|
| 75 | { | 
|---|
| 76 | //  Vector v(0.0, 0.0, 1.0); | 
|---|
| 77 | //  Quaternion q(10.0, v); | 
|---|
| 78 | //  this->setRelDir(&(this->relDirection * q)); | 
|---|
| 79 | } | 
|---|
| 80 |  | 
|---|
| 81 | /** | 
|---|
| 82 | \brief drawing function of the object | 
|---|
| 83 | */ | 
|---|
| 84 | void Primitive::draw () | 
|---|
| 85 | { | 
|---|
| 86 | glMatrixMode(GL_MODELVIEW); | 
|---|
| 87 | glPushMatrix(); | 
|---|
| 88 |  | 
|---|
| 89 | float matrix[4][4]; | 
|---|
| 90 | glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z); | 
|---|
| 91 | //rotate | 
|---|
| 92 | //this->getAbsDir().matrix (matrix); | 
|---|
| 93 | //glMultMatrixf((float*)matrix); | 
|---|
| 94 | this->material->select(); | 
|---|
| 95 | gluSphere(this->object, 2, 20, 20); | 
|---|
| 96 |  | 
|---|
| 97 | glPopMatrix(); | 
|---|
| 98 | } | 
|---|
| 99 |  | 
|---|