-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCrosshairOp.cpp
73 lines (64 loc) · 1.79 KB
/
CrosshairOp.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "CrosshairOp.h"
#include "global.h"
#include "HUD.h"
template<> CrosshairOperator *Ogre::Singleton<CrosshairOperator>::ms_Singleton=0;
CrosshairOperator::CrosshairOperator()
{
}
CrosshairOperator::~CrosshairOperator()
{
}
void CrosshairOperator::init()
{
}
Vector3 CrosshairOperator::getCrosshairShift(void)
{
x = global::getSingleton().getPlayer()->camera_rotation_x*5;
y = global::getSingleton().getPlayer()->camera_rotation_y*5;
//HUD::getSingleton().setCrosshairShiftTopLeft(x,y);
return Vector3::ZERO;
}
Vector3 CrosshairOperator::getCrosshairShift(Real x1,Real y1)
{
x = x1;
y = y1;
//HUD::getSingleton().setCrosshairShiftTopLeft(x,y);
return Vector3::ZERO;
}
void CrosshairOperator::upd(const FrameEvent& evt)
{
if ((fabs(x)>0)||(fabs(y)>0))
{
if ((x!=0)&&(y!=0))
HUD::getSingleton().setCrosshairShiftTopLeft((fabs(y)/y)*(fabs(y)-evt.timeSinceLastFrame),(fabs(x)/x)*(fabs(x)-evt.timeSinceLastFrame));
if ((x!=0)&&(y==0))
HUD::getSingleton().setCrosshairShiftTopLeft(0,(fabs(x)/x)*(fabs(x)-evt.timeSinceLastFrame));
if ((x==0)&&(y!=0))
HUD::getSingleton().setCrosshairShiftTopLeft((fabs(y)/y)*(fabs(y)-evt.timeSinceLastFrame),0);
//(fabs(y)/y) returns a sign of float, second part returns value
/*if (x!=0)&&
HUD::getSingleton().setCrosshairShiftTopLeft(*(fabs(y)-evt.timeSinceLastFrame),(x/fabs(x))*(fabs(x)-evt.timeSinceLastFrame));*/
if ((fabs(y)-evt.timeSinceLastFrame)<0)
y=0;
if ((fabs(x)-evt.timeSinceLastFrame)<0)
x=0;
}
else
{
/*if (x=<0)
{
x=0;
HUD::getSingleton().setCrosshairShiftTopLeft(y-evt.timeSinceLastFrame,0);
}
if (y=<0)
{
y=0;
HUD::getSingleton().setCrosshairShiftTopLeft(0,x-evt.timeSinceLastFrame);
}
if ((x=<0)&&(y=<0))*/
HUD::getSingleton().setCrosshairShiftTopLeft(0,0);
}
}
void CrosshairOperator::cleanup()
{
}