Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/levelLoader.tmp/src/world_entities/satellite.cc @ 3899

Last change on this file since 3899 was 3750, checked in by patrick, 20 years ago

orxonox/trunk: made some sattelite object just for fun and to show on the convention tomarrow

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 "satellite.h"
20
21#include "objModel.h"
22#include "list.h"
23#include "vector.h"
24
25
26using namespace std;
27
28/**
29   \brief standard constructor
30*/
31Satellite::Satellite (Vector axis, float speed)
32{
33  this->setClassName ("Satellite");
34  this->model = (Model*) ResourceManager::getInstance()->load("cube", RP_LEVEL);
35  this->speed = speed;
36  this->axis = new Vector();
37  *this->axis = axis;
38}
39
40/**
41   \brief standard destructor
42*/
43Satellite::~Satellite ()
44{
45  // if( collisioncluster != NULL) delete collisioncluster;
46  if (this->model)
47    ResourceManager::getInstance()->unload(this->model);
48}
49
50
51/**
52   \brief this method is called every frame
53   \param time: the time in seconds that has passed since the last tick
54   
55   Handle all stuff that should update with time inside this method (movement, animation, etc.)
56*/
57void Satellite::tick(float time) 
58{
59  float w = this->speed * M_PI;
60
61  Quaternion rotation(w * time, *this->axis); 
62  Quaternion v = this->getRelDir();
63 
64  this->setRelDir(v * rotation);
65}
66
67
68/**
69   \brief the entity is drawn onto the screen with this function
70   
71   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.
72*/
73void Satellite::draw() 
74{
75  glMatrixMode(GL_MODELVIEW);
76  glPushMatrix();
77  float matrix[4][4];
78 
79  /* translate */
80  glTranslatef (this->getAbsCoor ().x, 
81                this->getAbsCoor ().y, 
82                this->getAbsCoor ().z);
83  /* rotate */
84  this->getAbsDir ().matrix (matrix);
85  glMultMatrixf((float*)matrix);
86 
87  this->model->draw();
88  glPopMatrix();
89
90}
91
Note: See TracBrowser for help on using the repository browser.