Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/satellite.cc @ 5770

Last change on this file since 5770 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 
[3750]1
2
[4597]3/*
[3750]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
[4597]15   co-programmer:
[3750]16*/
[5357]17#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
[3750]18
19
20#include "satellite.h"
21
22#include "objModel.h"
23#include "list.h"
24#include "vector.h"
25
26
27using namespace std;
28
29/**
[4836]30 *  standard constructor
[3750]31*/
32Satellite::Satellite (Vector axis, float speed)
33{
[4320]34  this->setClassID(CL_SATELLITE, "Satellite");
[4597]35
[3750]36  this->model = (Model*) ResourceManager::getInstance()->load("cube", RP_LEVEL);
37  this->speed = speed;
38  this->axis = new Vector();
39  *this->axis = axis;
40}
41
42/**
[4836]43 *  standard destructor
[3750]44*/
45Satellite::~Satellite ()
46{
47}
48
49
50/**
[4836]51 *  this method is called every frame
52 * @param time: the time in seconds that has passed since the last tick
[4597]53
[3750]54   Handle all stuff that should update with time inside this method (movement, animation, etc.)
55*/
[4597]56void Satellite::tick(float time)
[3750]57{
58  float w = this->speed * M_PI;
59
[4597]60  Quaternion rotation(w * time, *this->axis);
[3750]61  Quaternion v = this->getRelDir();
[4597]62
[3750]63  this->setRelDir(v * rotation);
64}
65
66
67/**
[4836]68 *  the entity is drawn onto the screen with this function
[4597]69
[3750]70   This is a central function of an entity: call it to let the entity painted to the screen. Just override this function with whatever you want to be drawn.
71*/
[5500]72void Satellite::draw() const
[3750]73{
74  glMatrixMode(GL_MODELVIEW);
75  glPushMatrix();
76  float matrix[4][4];
[4597]77
[3750]78  /* translate */
[4597]79  glTranslatef (this->getAbsCoor ().x,
80                this->getAbsCoor ().y,
81                this->getAbsCoor ().z);
[3750]82  /* rotate */
83  this->getAbsDir ().matrix (matrix);
84  glMultMatrixf((float*)matrix);
[4597]85
[3750]86  this->model->draw();
87  glPopMatrix();
88
89}
90
Note: See TracBrowser for help on using the repository browser.