00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "DAEffect.h"
00022
00023 #include "system.h"
00024 #include <GL/gl.h>
00025 #include <GL/glu.h>
00026 #include <math.h>
00027
00028 #include "Level.h"
00029
00030 DAEffect::DAEffect(Vector3i p_origin, Vector3i p_destination, int p_valOrig, int p_valDest, Level* p_level)
00031 {
00032 origin = p_origin;
00033 destination = p_destination;
00034 valOrig = p_valOrig;
00035 valDest = p_valDest;
00036 level = p_level;
00037 }
00038
00039 DAEffect::~DAEffect()
00040 {
00041 }
00042
00043 int DAEffect::render()
00044 {
00045 int ret = 0;
00046 ratio = 2.0;
00047 Vector3d ori, dest;
00048
00049 ori.x = origin.x * 0.75;
00050 ori.y = origin.y * 0.87;
00051 if (origin.x % 2 == 1)
00052 {
00053 ori.y += 0.44;
00054 }
00055
00056 dest.x = destination.x * 0.75;
00057 dest.y = destination.y * 0.87;
00058 if (destination.x % 2 == 1)
00059 {
00060 dest.y += 0.44;
00061 }
00062
00063 Vector3d delta = dest - ori;
00064 double size = delta.length();
00065 ratio *= size;
00066 double angle = 0.0;
00067 if (origin.x == destination.x)
00068 {
00069 if (origin.y > destination.y)
00070 angle = 270.0;
00071 else
00072 angle = 90.0;
00073 }
00074 else
00075 {
00076 angle = (atan(delta.y / delta.x)* 57.3);
00077 if (ori.x < dest.x)
00078 {
00079 angle = 360 + angle;
00080 }
00081 else
00082 {
00083 angle = 180 + angle;
00084 }
00085 }
00086
00087 glPushMatrix();
00088
00089 glTranslated(0.0, 0.065, 0.0);
00090 delta /= 2.0;
00091 delta += ori;
00092 glTranslated(delta.x, delta.y, delta.z);
00093 glRotated(angle, 0.0, 0.0, 1.0);
00094 glScaled(size, size, size);
00095 Texture::render();
00096 glPopMatrix();
00097
00098
00099 Vector3d origColor, destColor;
00100 if ((valOrig < valDest) && (valDest != 99))
00101 {
00102 origColor.x = 1.0;
00103 destColor.y = 1.0;
00104 }
00105 else
00106 {
00107 destColor.x = 1.0;
00108 origColor.y = 1.0;
00109 }
00110 glPushMatrix();
00111
00112 glTranslated(0.0, 0.065, 0.0);
00113 glColor4d(origColor.x, origColor.y, origColor.z, 1.0);
00114 level->glPrint2d(ori.x, ori.y, "%i", valOrig);
00115 glColor4d(destColor.x, destColor.y, destColor.z, 1.0);
00116 if (valDest != 99)
00117 level->glPrint2d(dest.x, dest.y, "%i", valDest);
00118 else
00119 level->glPrint2d(dest.x, dest.y, "E");
00120 glPopMatrix();
00121 return ret;
00122 }