Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/hud2/src/orxonox/hud/RadarOverlayElement.cc @ 1218

Last change on this file since 1218 was 1218, checked in by chaiy, 17 years ago

-.-

File size: 2.4 KB
Line 
1/*
2*   ORXONOX - the hottest 3D action shooter ever to exist
3*
4*
5*   License notice:
6*
7*   This program is free software; you can redistribute it and/or
8*   modify it under the terms of the GNU General Public License
9*   as published by the Free Software Foundation; either version 2
10*   of the License, or (at your option) any later version.
11*
12*   This program is distributed in the hope that it will be useful,
13*   but WITHOUT ANY WARRANTY; without even the implied warranty of
14*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*   GNU General Public License for more details.
16*
17*   You should have received a copy of the GNU General Public License
18*   along with this program; if not, write to the Free Software
19*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20*
21*   Author:
22*      Yuning Chai
23*   Co-authors:
24*      ...
25*
26*/
27
28#include <OgreOverlayManager.h>
29#include <OgreOverlayElement.h>
30#include <OgreStringConverter.h>
31#include <math.h>
32#include <string.h>
33
34#include "RadarOverlayElement.h"
35
36
37namespace orxonox
38{
39  using namespace Ogre;
40
41  RadarOverlayElement::RadarOverlayElement(const String& name):Ogre::PanelOverlayElement(name){}
42
43  RadarOverlayElement::~RadarOverlayElement(){}
44
45  void RadarOverlayElement::initialise(){
46    PanelOverlayElement::initialise();
47  }
48 
49  void RadarOverlayElement::initRadarOverlayElement(){
50    int dirX, dirY, dirZ;      //flying direction
51    int ortX, ortY, ortZ;      //orthogonal direction
52    int dX, dY, dZ;            //distance between main ship and the object
53    int vecX, vecY, vecZ;      //vector product dir X ort
54    double alpha;              //defines the radius in the radar
55    double beta;               //defines the angle in the radar
56    bool right;                //checks whether the object is on the right side (since cos is not bijective)
57   
58    dirX = 1;
59    dirY = 0;
60    dirZ = 0;
61   
62    ortX = 0;
63    ortY = 0;
64    ortZ = 1;
65   
66    dX = 2;
67    dY = 0;
68    dZ = 0;
69   
70    alpha = acos((dirX*dX+dirY*dY+dirZ*dZ)/(sqrt(pow(dX,2)+pow(dY,2)+pow(dZ,2))+sqrt(pow(dirX,2)+pow(dirY,2)+pow(dirZ,2))));
71    beta = acos((ortX*X+ortY*dY+ortZ*dZ)/(sqrt(pow(dX,2)+pow(dY,2)+pow(dZ,2))+sqrt(pow(ortX,2)+pow(ortY,2)+pow(ortZ,2))));
72    vecX = dirY*ortZ - dirZ*ortY;
73    vecY = dirZ*ortX - dirX*ortZ;
74    vecZ = dirX*ortY - dirY*ortX;
75   
76    if((vecX*dX+vecY*dY+vecZ*dZ)>0){right=true;}
77    else right=false;
78
79
80}
81
82
Note: See TracBrowser for help on using the repository browser.