#include "mapviewer.h" using namespace std; void CSky::Draw() { int i; GLfloat pos[3]; color skytop, skybot; color suncore, suncorona; color bottomcloud, topcloud; GLfloat SunSz, SprSz; GLfloat FogCol[4]; GLfloat FogSt, FarClp; GLfloat objtocam[3], objtocamproj[3]; GLfloat d; GLfloat c; GLfloat ang; GetSky_top(skytop); GetSky_bot(skybot); Camera.GetPosition(&pos[0], &pos[1], &pos[2]); glBindTexture(GL_TEXTURE_2D, 0); /* Draw Sky */ glDisable(GL_DEPTH_TEST); glDisable(GL_FOG); glDisable(GL_LIGHTING); glPushMatrix(); glTranslatef(pos[0], pos[1], 0); glRotatef(Camera.GetYaw()*180/M_PI, 0.0f, 0.0f, 1.0f); glBegin(GL_QUADS); glColor3ubv(skytop); glVertex3f(1000, -3000, 500); glVertex3f(1000, 3000, 500); glColor3ubv(skybot); glVertex3f(1000, 3000, 0); glVertex3f(1000, -3000, 0); if ((Game.GetVersion() & GAMESANANDREAS) != 0) glColor3ubv(skytop); else glColor3ub(128, 128, 128); glVertex3f(1000, 3000, 0); glVertex3f(1000, -3000, 0); glVertex3f(0, -3000, 0); glVertex3f(0, 3000, 0); glEnd(); glPopMatrix(); /* Draw Sun (only III and VC) */ if (!(Game.GetVersion() & GAMESANANDREAS)) { SprSz = GetSprSz(); SunSz = GetSunSz(); if (Camera.isTranslatedSphereInFrustum(SunPos, SprSz)) { GetSunCore(suncore); GetSunCorona(suncorona); objtocamproj[0] = -SunPos[0]; objtocamproj[1] = -SunPos[1]; objtocamproj[2] = 0; /* normalize */ d = sqrt(objtocamproj[0]*objtocamproj[0] + objtocamproj[1]*objtocamproj[1] + objtocamproj[2]*objtocamproj[2]); objtocamproj[0] /= d; objtocamproj[1] /= d; objtocamproj[2] /= d; c = objtocamproj[1]; glPushMatrix(); glTranslatef(pos[0], pos[1], pos[2]); glTranslatef(SunPos[0], SunPos[1], SunPos[2]); glRotatef(acos(c)*180/M_PI, 0, 0, -objtocamproj[0]); objtocam[0] = -SunPos[0]; objtocam[1] = -SunPos[1]; objtocam[2] = -SunPos[2]; /* normalize */ d = sqrt(objtocam[0]*objtocam[0] + objtocam[1]*objtocam[1] + objtocam[2]*objtocam[2]); objtocam[0] /= d; objtocam[1] /= d; objtocam[2] /= d; c = objtocamproj[0] * objtocam[0] + objtocamproj[1] * objtocam[1] + objtocamproj[2] * objtocam[2]; glRotatef(acos(c)*180/M_PI, objtocam[2], 0, 0); glColor4ub(suncore[0], suncore[1], suncore[2], 255); glPushMatrix(); glScalef(SprSz, SprSz, SprSz); DrawSprite("PARTICLE", "shad_exp", true); glPopMatrix(); // glColor4ub(suncorona[0], suncorona[1], suncorona[2], 255); // glPushMatrix(); // glScalef(SunSz, SunSz, SunSz); // DrawSprite("PARTICLE", "corona", true); // glPopMatrix(); glPopMatrix(); } } /* Draw far away Clouds (only III and VC) */ if (!(Game.GetVersion() & GAMESANANDREAS)) { GetBottomCloudRGB(bottomcloud); GetTopCloudRGB(topcloud); ang = 0; for (i = 0; i < 5; i++) { glColor4ub(bottomcloud[0], bottomcloud[1], bottomcloud[2], 255); DrawCloud(BottomClouds[i].TexName, BottomClouds[i].Position); glColor4ub(topcloud[0], topcloud[1], topcloud[2], 50); DrawCloud(TopClouds[i].TexName, TopClouds[i].Position); } } if (GLView.UseFog()) { FogSt = GetFogSt(); FarClp = GetFarClp(); glEnable(GL_FOG); FogCol[0] = (GLfloat)skybot[0]/255.0f; FogCol[1] = (GLfloat)skybot[1]/255.0f; FogCol[2] = (GLfloat)skybot[2]/255.0f; FogCol[3] = 0; glFogfv(GL_FOG_COLOR, FogCol); glFogi(GL_FOG_MODE, GL_LINEAR); glFogf(GL_FOG_START, FogSt); glFogf(GL_FOG_END, FarClp); if ((Game.GetVersion() & GAMESANANDREAS) != 0) { glFogi(GL_FOG_MODE, GL_EXP2); glFogf(GL_FOG_DENSITY, 0.0025f); } } glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); } void CSky::DrawSunCorona() { GLfloat pos[3]; color suncorona; GLfloat SunSz, SprSz; GLfloat objtocam[3], objtocamproj[3]; GLfloat d; GLfloat c; /* This should be temporary */ if ((Game.GetVersion() & GAMESANANDREAS)) return; Camera.GetPosition(&pos[0], &pos[1], &pos[2]); glDisable(GL_DEPTH_TEST); glDisable(GL_FOG); glDisable(GL_LIGHTING); SunSz = GetSunSz(); SprSz = GetSprSz(); if (Camera.isTranslatedSphereInFrustum(SunPos, SprSz)) { GetSunCorona(suncorona); objtocamproj[0] = -SunPos[0]; objtocamproj[1] = -SunPos[1]; objtocamproj[2] = 0; /* normalize */ d = sqrt(objtocamproj[0]*objtocamproj[0] + objtocamproj[1]*objtocamproj[1] + objtocamproj[2]*objtocamproj[2]); objtocamproj[0] /= d; objtocamproj[1] /= d; objtocamproj[2] /= d; c = objtocamproj[1]; glPushMatrix(); glTranslatef(pos[0], pos[1], pos[2]); glTranslatef(SunPos[0], SunPos[1], SunPos[2]); glRotatef(acos(c)*180/M_PI, 0, 0, -objtocamproj[0]); objtocam[0] = -SunPos[0]; objtocam[1] = -SunPos[1]; objtocam[2] = -SunPos[2]; /* normalize */ d = sqrt(objtocam[0]*objtocam[0] + objtocam[1]*objtocam[1] + objtocam[2]*objtocam[2]); objtocam[0] /= d; objtocam[1] /= d; objtocam[2] /= d; c = objtocamproj[0] * objtocam[0] + objtocamproj[1] * objtocam[1] + objtocamproj[2] * objtocam[2]; glRotatef(acos(c)*180/M_PI, objtocam[2], 0, 0); glColor4ub(suncorona[0], suncorona[1], suncorona[2], 255); glPushMatrix(); glScalef(SunSz, SunSz, SunSz); DrawSprite("PARTICLE", "corona", true); glPopMatrix(); glPopMatrix(); } glEnable(GL_DEPTH_TEST); if (GLView.UseFog()) glEnable(GL_FOG); glEnable(GL_LIGHTING); } void CSky::DrawCloud(const char *TexName, GLfloat *Pos) { // GLfloat ObjToCamProj[3], LookAt[3], UpAux[3]; GLfloat CamPos[3], ObjPos[3]; // GLfloat d, c; Camera.GetPosition(&CamPos[0], &CamPos[1], &CamPos[2]); glPushMatrix(); ObjPos[0] = CamPos[0] + Pos[0]; ObjPos[1] = CamPos[1] + Pos[1]; ObjPos[2] = CamPos[2] + Pos[2]; #if 0 ObjToCamProj[0] = CamPos[0] - ObjPos[0]; ObjToCamProj[1] = CamPos[1] - ObjPos[1]; ObjToCamProj[2] = 0; LookAt[0] = 0; LookAt[1] = 1; LookAt[2] = 0; /* normalize */ d = sqrt(ObjToCamProj[0]*ObjToCamProj[0] + ObjToCamProj[1]*ObjToCamProj[1] + ObjToCamProj[2]*ObjToCamProj[2]); ObjToCamProj[0] /= d; ObjToCamProj[1] /= d; ObjToCamProj[2] /= d; /* Cross product */ UpAux[0] = LookAt[1]*ObjToCamProj[2] - LookAt[2]*ObjToCamProj[1]; UpAux[1] = LookAt[2]*ObjToCamProj[0] - LookAt[0]*ObjToCamProj[2]; UpAux[2] = LookAt[0]*ObjToCamProj[1] - LookAt[1]*ObjToCamProj[0]; c = LookAt[0] * ObjToCamProj[0] + LookAt[1] * ObjToCamProj[1] + LookAt[2] * ObjToCamProj[2]; #endif glTranslatef(ObjPos[0], ObjPos[1], ObjPos[2]); glRotatef(Camera.GetYaw()*180/M_PI+90, 0, 0, 1); // glRotatef(acos(c)*180/M_PI, 0, 0, UpAux[2]); glScalef(200, 200, 20); DrawSprite("PARTICLE", TexName, true); glPopMatrix(); } void CSky::DrawTint() { color tintcol; int w, h; w = GLView.getWidth(); h = GLView.getHeight(); GetTintColor(tintcol); glBindTexture(GL_TEXTURE_2D, 0); glEnable(GL_BLEND); glColor4ubv(tintcol); glBegin(GL_POLYGON); glVertex2f(0, h); glVertex2f(w, h); glVertex2f(w, 0); glVertex2f(0, 0); glEnd(); } void CSky::UpdateSun() { int TimeInMin; GLfloat r; TimeInMin = Clock.GetHour()*60 + Clock.GetMinute(); r = 4; /* Convert to Radians and add 8 hours */ SunPos[0] = cos(TimeInMin/230.0f - M_PI/2.0f)*r; SunPos[1] = sin(TimeInMin/230.0f - M_PI/2.0f)*r/2+3; SunPos[2] = sin(TimeInMin/230.0f - M_PI/2.0f)*r*2+1; r = sqrt(SunPos[0]*SunPos[0] + SunPos[1]*SunPos[1] + SunPos[2]*SunPos[2]); /* Make the distance 4 units long */ SunPos[0] /= r/4.0f; SunPos[1] /= r/4.0f; SunPos[2] /= r/4.0f; } void CSky::UpdateLight(void) { GLfloat lgtamb[4]; GLfloat lgtdif[4]; GLfloat lgtpos[4]; // byte raw_light[3]; if (LightModel == AMBIENT_ONLY) { /* cout << "ambient\n"; GetAmb(raw_light); lgtamb[0] = (GLfloat) raw_light[0] / 255.0f; lgtamb[1] = (GLfloat) raw_light[1] / 255.0f; lgtamb[2] = (GLfloat) raw_light[2] / 255.0f; lgtamb[3] = 1.0f; */ lgtamb[0] = 1.0f; lgtamb[1] = 1.0f; lgtamb[2] = 1.0f; lgtamb[3] = 1.0f; lgtdif[0] = 0.0f; lgtdif[1] = 0.0f; lgtdif[2] = 0.0f; lgtdif[3] = 1.0f; glLightfv(GL_LIGHT0, GL_AMBIENT, lgtamb); glLightfv(GL_LIGHT0, GL_DIFFUSE, lgtdif); } else if (LightModel == AMBIENT_AND_DIFFUSE) { lgtamb[0] = 0.5f; lgtamb[1] = 0.5f; lgtamb[2] = 0.5f; lgtamb[3] = 0.5f; lgtdif[0] = 1.0f; lgtdif[1] = 1.0f; lgtdif[2] = 1.0f; lgtdif[3] = 1.0f; /* cout << "ambient and diffuse\n"; GetAmb_Obj(raw_light); lgtamb[0] = (GLfloat) raw_light[0] / 255.0f; lgtamb[1] = (GLfloat) raw_light[1] / 255.0f; lgtamb[2] = (GLfloat) raw_light[2] / 255.0f; lgtamb[3] = 1.0f; GetDir(raw_light); lgtdif[0] = (GLfloat) raw_light[0] / 255.0f; lgtdif[1] = (GLfloat) raw_light[1] / 255.0f; lgtdif[2] = (GLfloat) raw_light[2] / 255.0f; lgtdif[3] = 1.0f; */ lgtpos[0] = SunPos[0]*1000.0f; lgtpos[1] = SunPos[1]*1000.0f; lgtpos[2] = SunPos[2]*1000.0f; lgtpos[0] = 1.0f; glLightfv(GL_LIGHT0, GL_POSITION, lgtpos); glLightfv(GL_LIGHT0, GL_AMBIENT, lgtamb); glLightfv(GL_LIGHT0, GL_DIFFUSE, lgtdif); } } void CSky::Init() { int i; GLfloat ang; GLfloat r; const char *texnames[] = { "cloud1", "cloud2", "cloud3" }; LightModel = AMBIENT_ONLY; r = 400; ang = 0; srand(2); for (i = 0; i < 5; i++) { BottomClouds[i].Position[0] = cos(ang)*r; BottomClouds[i].Position[1] = sin(ang)*r; BottomClouds[i].Position[2] = rand() % 40; strcpy(BottomClouds[i].TexName, texnames[rand()%3]); ang += 2.0f*M_PI/5.0f; } ang = 2.0f*M_PI/10.0f; for (i = 0; i < 5; i++) { TopClouds[i].Position[0] = cos(ang)*r; TopClouds[i].Position[1] = sin(ang)*r; TopClouds[i].Position[2] = rand() % 40 + 55; strcpy(TopClouds[i].TexName, texnames[rand()%3]); ang += 2.0f*M_PI/5.0f; } ReadWeatherData(); } void CSky::GetWaterColor(byte *color) { byte *water1, *water2; water1 = WeatherList[Clock.GetHour()+WeatherSelector*24].WaterRGBA; Clock.AdvanceOneHour(); water2 = WeatherList[Clock.GetHour()+WeatherSelector*24].WaterRGBA; Clock.TurnBackOneHour(); MixColors(color, water1, water2, 60-Clock.GetMinute(), 60); } void CSky::GetSunCore(byte *color) { byte *sun1, *sun2; sun1 = WeatherList[Clock.GetHour()+WeatherSelector*24].SunCore; Clock.AdvanceOneHour(); sun2 = WeatherList[Clock.GetHour()+WeatherSelector*24].SunCore; Clock.TurnBackOneHour(); MixColors(color, sun1, sun2, 60-Clock.GetMinute(), 60); } void CSky::GetSunCorona(byte *color) { byte *sun1, *sun2; sun1 = WeatherList[Clock.GetHour()+WeatherSelector*24].SunCorona; Clock.AdvanceOneHour(); sun2 = WeatherList[Clock.GetHour()+WeatherSelector*24].SunCorona; Clock.TurnBackOneHour(); MixColors(color, sun1, sun2, 60-Clock.GetMinute(), 60); } void CSky::GetTintColor(byte *color) { byte *tint1, *tint2; tint1 = WeatherList[Clock.GetHour()+WeatherSelector*24].Tint; Clock.AdvanceOneHour(); tint2 = WeatherList[Clock.GetHour()+WeatherSelector*24].Tint; Clock.TurnBackOneHour(); MixColors(color, tint1, tint2, 60-Clock.GetMinute(), 60); color[0] = (byte) (color[0] * 0.6); color[1] = (byte) (color[1] * 0.6); color[2] = (byte) (color[2] * 0.6); color[3] = (byte) (color[3] * 0.6); } void CSky::GetSky_top(byte *color) { byte *top1, *top2; top1 = WeatherList[Clock.GetHour()+WeatherSelector*24].Sky_top; Clock.AdvanceOneHour(); top2 = WeatherList[Clock.GetHour()+WeatherSelector*24].Sky_top; Clock.TurnBackOneHour(); MixColors(color, top1, top2, 60-Clock.GetMinute(), 60); } void CSky::GetSky_bot(byte *color) { byte *bot1, *bot2; bot1 = WeatherList[Clock.GetHour()+WeatherSelector*24].Sky_bot; Clock.AdvanceOneHour(); bot2 = WeatherList[Clock.GetHour()+WeatherSelector*24].Sky_bot; Clock.TurnBackOneHour(); MixColors(color, bot1, bot2, 60-Clock.GetMinute(), 60); } void CSky::GetDir(byte *color) { byte *dir1, *dir2; dir1 = WeatherList[Clock.GetHour()+WeatherSelector*24].Dir; Clock.AdvanceOneHour(); dir2 = WeatherList[Clock.GetHour()+WeatherSelector*24].Dir; Clock.TurnBackOneHour(); MixColors(color, dir1, dir2, 60-Clock.GetMinute(), 60); } void CSky::GetAmb(byte *color) { byte *amb1, *amb2; amb1 = WeatherList[Clock.GetHour()+WeatherSelector*24].Amb; Clock.AdvanceOneHour(); amb2 = WeatherList[Clock.GetHour()+WeatherSelector*24].Amb; Clock.TurnBackOneHour(); MixColors(color, amb1, amb2, 60-Clock.GetMinute(), 60); } void CSky::GetAmb_Obj(byte *color) { byte *amb1, *amb2; amb1 = WeatherList[Clock.GetHour()+WeatherSelector*24].Amb_Obj; Clock.AdvanceOneHour(); amb2 = WeatherList[Clock.GetHour()+WeatherSelector*24].Amb_Obj; Clock.TurnBackOneHour(); MixColors(color, amb1, amb2, 60-Clock.GetMinute(), 60); } void CSky::GetLowCloudsRGB(byte *color) { byte *cld1, *cld2; cld1 = WeatherList[Clock.GetHour()+WeatherSelector*24].LowCloudsRGB; Clock.AdvanceOneHour(); cld2 = WeatherList[Clock.GetHour()+WeatherSelector*24].LowCloudsRGB; Clock.TurnBackOneHour(); MixColors(color, cld1, cld2, 60-Clock.GetMinute(), 60); } void CSky::GetTopCloudRGB(byte *color) { byte *cld1, *cld2; cld1 = WeatherList[Clock.GetHour()+WeatherSelector*24].TopCloudRGB; Clock.AdvanceOneHour(); cld2 = WeatherList[Clock.GetHour()+WeatherSelector*24].TopCloudRGB; Clock.TurnBackOneHour(); MixColors(color, cld1, cld2, 60-Clock.GetMinute(), 60); } void CSky::GetBottomCloudRGB(byte *color) { byte *cld1, *cld2; cld1 = WeatherList[Clock.GetHour()+WeatherSelector*24].BottomCloudRGB; Clock.AdvanceOneHour(); cld2 = WeatherList[Clock.GetHour()+WeatherSelector*24].BottomCloudRGB; Clock.TurnBackOneHour(); MixColors(color, cld1, cld2, 60-Clock.GetMinute(), 60); } GLfloat CSky::GetFarClp() { GLfloat FarClp1, FarClp2; FarClp1 = WeatherList[Clock.GetHour()+WeatherSelector*24].FarClp; Clock.AdvanceOneHour(); FarClp2 = WeatherList[Clock.GetHour()+WeatherSelector*24].FarClp; Clock.TurnBackOneHour(); return (FarClp1*(60-Clock.GetMinute()) + FarClp2*Clock.GetMinute())/60.0f; } GLfloat CSky::GetFogSt() { GLfloat FogSt1, FogSt2; FogSt1 = WeatherList[Clock.GetHour()+WeatherSelector*24].FogSt; Clock.AdvanceOneHour(); FogSt2 = WeatherList[Clock.GetHour()+WeatherSelector*24].FogSt; Clock.TurnBackOneHour(); return (FogSt1*(60-Clock.GetMinute()) + FogSt2*Clock.GetMinute())/60.0f; } GLfloat CSky::GetSunSz() { GLfloat SunSz1, SunSz2; SunSz1 = WeatherList[Clock.GetHour()+WeatherSelector*24].SunSz; Clock.AdvanceOneHour(); SunSz2 = WeatherList[Clock.GetHour()+WeatherSelector*24].SunSz; Clock.TurnBackOneHour(); return (SunSz1*(60-Clock.GetMinute()) + SunSz2*Clock.GetMinute())/60.0f; } GLfloat CSky::GetSprSz() { GLfloat SprSz1, SprSz2; SprSz1 = WeatherList[Clock.GetHour()+WeatherSelector*24].SprSz; Clock.AdvanceOneHour(); SprSz2 = WeatherList[Clock.GetHour()+WeatherSelector*24].SprSz; Clock.TurnBackOneHour(); return (SprSz1*(60-Clock.GetMinute()) + SprSz2*Clock.GetMinute())/60.0f; } int CSky::GetWeatherSelector() { return WeatherSelector; } void CSky::SetSunPos(const GLfloat x, const GLfloat y, const GLfloat z) { SunPos[0] = x; SunPos[1] = y; SunPos[2] = z; } void CSky::Clear() { color skytop; GetSky_top(skytop); glClearColor(skytop[0]/255.0, skytop[1]/255.0, skytop[2]/255.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); } void CSky::NextWeather() { WeatherSelector++; printf("%d\n", numWeather); if (WeatherSelector >= numWeather) WeatherSelector = 0; } void CSky::PreviousWeather() { WeatherSelector--; if (WeatherSelector < 0) WeatherSelector = numWeather-1; } void CSky::SetLightModel(int m) { LightModel = m; } void CSky::ReadWeatherData() { int i; int numEntries; char buffer[512]; char *pos; FILE *timecyc; SWeather weather; timecyc = efopen("DATA/TIMECYC.DAT", "r"); if ((Game.GetVersion() & GAMEIII) != 0) { numWeather = 4; numEntries = 24; } else if ((Game.GetVersion() & GAMEVICECITY) != 0) { numWeather = 6; numEntries = 24; } else { numWeather = 23; numEntries = 8; } for (i = 0; i < numWeather*numEntries; i++) { ReadConfigLine(timecyc, buffer); pos = buffer; if ((Game.GetVersion() & GAMEIII) != 0) { sscanf(buffer, "%hhu %hhu %hhu" "%hhu %hhu %hhu %hhu %hhu %hhu" "%hhu %hhu %hhu %hhu %hhu %hhu" "%hhu %hhu %hhu %f %f %f %d %d %d %f %f %f" "%hhu %hhu %hhu %hhu %hhu %hhu" "%hhu %hhu %hhu %hhu %hhu %hhu %hhu", &weather.Amb[0], &weather.Amb[1],&weather.Amb[2], &weather.Dir[0], &weather.Dir[1],&weather.Dir[2], &weather.Sky_top[0], &weather.Sky_top[1], &weather.Sky_top[2], &weather.Sky_bot[0], &weather.Sky_bot[1], &weather.Sky_bot[2], &weather.SunCore[0], &weather.SunCore[1], &weather.SunCore[2], &weather.SunCorona[0], &weather.SunCorona[1], &weather.SunCorona[2], &weather.SunSz, &weather.SprSz, &weather.SprBght, &weather.Shdw, &weather.LightShd, &weather.TreeShd, &weather.FarClp, &weather.FogSt, &weather.LightOnGround, &weather.LowCloudsRGB[0], &weather.LowCloudsRGB[1], &weather.LowCloudsRGB[2], &weather.TopCloudRGB[0], &weather.TopCloudRGB[1], &weather.TopCloudRGB[2], &weather.BottomCloudRGB[0], &weather.BottomCloudRGB[1], &weather.BottomCloudRGB[2], &weather.Tint[0], &weather.Tint[1], &weather.Tint[2], &weather.Tint[3]); WeatherList.push_back(weather); } else if ((Game.GetVersion() & GAMEVICECITY) != 0) { sscanf(buffer, "%hhu %hhu %hhu %hhu %hhu %hhu" "%hhu %hhu %hhu %hhu %hhu %hhu" "%hhu %hhu %hhu %hhu %hhu %hhu" "%hhu %hhu %hhu %hhu %hhu %hhu" "%hhu %hhu %hhu %f %f %f %d %d %d %f %f %f" "%hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu" "%hhu %hhu %hhu %hhu %hhu %hhu %hhu", &weather.Amb[0], &weather.Amb[1],&weather.Amb[2], &weather.Amb_Obj[0], &weather.Amb_Obj[1], &weather.Amb_Obj[2], &weather.Amb_Bl[0], &weather.Amb_Bl[1], &weather.Amb_Bl[2], &weather.Amb_Obj_bl[0], &weather.Amb_Obj_bl[1], &weather.Amb_Obj_bl[2], &weather.Dir[0], &weather.Dir[1],&weather.Dir[2], &weather.Sky_top[0], &weather.Sky_top[1], &weather.Sky_top[2], &weather.Sky_bot[0], &weather.Sky_bot[1], &weather.Sky_bot[2], &weather.SunCore[0], &weather.SunCore[1], &weather.SunCore[2], &weather.SunCorona[0], &weather.SunCorona[1], &weather.SunCorona[2], &weather.SunSz, &weather.SprSz, &weather.SprBght, &weather.Shdw, &weather.LightShd, &weather.PoleShd, &weather.FarClp, &weather.FogSt, &weather.LightOnGround, &weather.LowCloudsRGB[0], &weather.LowCloudsRGB[1], &weather.LowCloudsRGB[2], &weather.TopCloudRGB[0], &weather.TopCloudRGB[1], &weather.TopCloudRGB[2], &weather.BottomCloudRGB[0], &weather.BottomCloudRGB[1], &weather.BottomCloudRGB[2], &weather.BlurRGB[0], &weather.BlurRGB[1], &weather.BlurRGB[2], &weather.WaterRGBA[0], &weather.WaterRGBA[1], &weather.WaterRGBA[2], &weather.WaterRGBA[3]); WeatherList.push_back(weather); } else { sscanf(buffer, "%hhu %hhu %hhu %hhu %hhu %hhu" "%hhu %hhu %hhu %hhu %hhu %hhu" "%hhu %hhu %hhu %hhu %hhu %hhu" "%hhu %hhu %hhu %f %f %f %d %d %d %f %f %f" "%hhu %hhu %hhu %hhu %hhu %hhu" "%hhu %hhu %hhu %hhu" "%hhu %hhu %hhu %hhu" "%hhu %hhu %hhu %hhu %f", &weather.Amb[0], &weather.Amb[1],&weather.Amb[2], &weather.Amb_Obj[0], &weather.Amb_Obj[1], &weather.Amb_Obj[2], &weather.Dir[0], &weather.Dir[1],&weather.Dir[2], &weather.Sky_top[0], &weather.Sky_top[1], &weather.Sky_top[2], &weather.Sky_bot[0], &weather.Sky_bot[1], &weather.Sky_bot[2], &weather.SunCore[0], &weather.SunCore[1], &weather.SunCore[2], &weather.SunCorona[0], &weather.SunCorona[1], &weather.SunCorona[2], &weather.SunSz, &weather.SprSz, &weather.SprBght, &weather.Shdw, &weather.LightShd, &weather.PoleShd, &weather.FarClp, &weather.FogSt, &weather.LightOnGround, &weather.LowCloudsRGB[0], &weather.LowCloudsRGB[1], &weather.LowCloudsRGB[2], &weather.TopCloudRGB[0], &weather.TopCloudRGB[1], &weather.TopCloudRGB[2], &weather.WaterRGBA[0], &weather.WaterRGBA[1], &weather.WaterRGBA[0], &weather.WaterRGBA[1], &weather.RGBA1[3], &weather.RGBA1[0], &weather.RGBA1[1], &weather.RGBA1[2], &weather.RGBA2[3], &weather.RGBA2[0], &weather.RGBA2[1], &weather.RGBA2[2], &weather.CloudAlpha); if (i == 0) { /* Midnight */ WeatherList.push_back(weather); WeatherList.push_back(weather); WeatherList.push_back(weather); WeatherList.push_back(weather); WeatherList.push_back(weather); } else if (i == 3) { /* 7AM */ WeatherList.push_back(weather); WeatherList.push_back(weather); WeatherList.push_back(weather); WeatherList.push_back(weather); WeatherList.push_back(weather); } else if (i == 4) { /* Midday */ WeatherList.push_back(weather); WeatherList.push_back(weather); WeatherList.push_back(weather); WeatherList.push_back(weather); WeatherList.push_back(weather); WeatherList.push_back(weather); WeatherList.push_back(weather); } else if (i == 6) { /* 8PM */ WeatherList.push_back(weather); WeatherList.push_back(weather); } else if (i == 7) { /* 10PM */ WeatherList.push_back(weather); } else { WeatherList.push_back(weather); } } } fclose(timecyc); } void CSky::Dump() { // int i; // for (i = 0; i < WeatherList.size(); i++) { // printf("%d %d %d\n", WeatherList[i].BottomCloudRGB[0], // WeatherList[i].BottomCloudRGB[1], // WeatherList[i].BottomCloudRGB[2]); // } } CSky::CSky() { numWeather = 0; WeatherSelector = 0; } CSky::~CSky() { }