diff --git a/server/main.cc b/server/main.cc index da1a2df..bec80fb 100644 --- a/server/main.cc +++ b/server/main.cc @@ -19,8 +19,8 @@ using namespace std; using namespace std::chrono; const uint32_t kMaxLeafSize = 8; -const string kDataFileName = "data/hygdata_min3.csv"; -// const string kDataFileName = "data/thc.csv"; +//const string kDataFileName = "data/hygdata_min3.csv"; +const string kDataFileName = "data/thc.csv"; // Signal handler sets this to false to stop the server volatile bool running = true; @@ -52,17 +52,17 @@ int main(int argc, char* argv[]) { double minx,miny,minz,maxx,maxy,maxz; vector stars; - //while(star_reader.read_row(idstr, x, y, z, absmag, r, g, b)) { - while(star_reader.read_row(id, x, y, z, lum, r, g, b)) { + while(star_reader.read_row(idstr, x, y, z, absmag, r, g, b)) { + //while(star_reader.read_row(id, x, y, z, lum, r, g, b)) { minx = min(x, minx); miny = min(y, miny); minz = min(z, minz); maxx = max(x, maxx); maxy = max(y, maxy); maxz = max(z, maxz); - //lum = exp(-0.4 * (absmag - 4.85)); - //stars.push_back(Star(id++, x, y , z, lum, r, g, b)); - stars.push_back(Star(id, x, y , z, lum, r, g, b)); + lum = exp(-0.4 * (absmag - 4.85)); + stars.push_back(Star(id++, x, y , z, lum, r, g, b)); + //stars.push_back(Star(id, x, y , z, lum, r, g, b)); } cout << "Min x: " << minx << " Min y: " << miny << " Min z: " << minz << endl diff --git a/server/static/client.js b/server/static/client.js index ae1d1f7..079193d 100644 --- a/server/static/client.js +++ b/server/static/client.js @@ -18,6 +18,7 @@ var draggingCanvas = false; var dragVector = {x: null, y: null}; var pressForward = false; var activeDrag = false; +var totalStarDownloadCount = 0; function initKeys() { for (var i = 0; i < 256; ++i) { @@ -177,33 +178,40 @@ function doOneFrame() { var translated = position.subtract(cameraPosition); var brightness = star.lum / (4 * Math.PI * translated.squaredLength()); + var scaling = 255 * 64; + brightness *= scaling; if (brightness < 0.001) { starSkipCount++; continue; } - var scaling = 255 * 8; - brightness *= scaling; var projected = translated.basisProjection(right, cameraDirection, upDirection); if (projected.y < 0.00001) { + starSkipCount++; continue; } + var fovMultiplier = 1.0 / 0.7; var sx = (canvas.width / 2) + - (canvas.width / 2) * projected.x / projected.y; + fovMultiplier * (canvas.width / 2) * projected.x / projected.y; var sy = (canvas.height / 2) + - (canvas.width / 2) * projected.z / projected.y; - if (sx < 0 || sx > canvas.width) continue; - if (sy < 0 || sy > canvas.height) continue; + fovMultiplier * (canvas.width / 2) * projected.z / projected.y; + if (sx < 0 || sx > canvas.width) { + starSkipCount++; + continue; + } + if (sy < 0 || sy > canvas.height) { + starSkipCount++; + continue; + } var color = {"r":star.r, "g":star.g, "b":star.b}; renderStar(context, sx, sy, brightness, color); starRenderCount++; } } - //console.log('Stars Rendered: ' + starRenderCount); - //console.log('Stars Skipped: ' + starSkipCount); + console.log('rendered: ' + starRenderCount + ' skipped: ' + starSkipCount); setTimeout(doOneFrame, 10); }; @@ -221,7 +229,7 @@ function updateStars(force) { var y = cameraPosition.y; var z = cameraPosition.z; //console.log('x: ' + x + ' y: ' + y + ' z: ' + z); - getVisibleOctants(0.001, x, y, z, function(newOcts) { + getVisibleOctants(0.0001, x, y, z, function(newOcts) { // Use a temporary so we don't update with this before we // actually have all thes tars. var tmpVisibleOctants = newOcts; @@ -250,8 +258,11 @@ function updateStars(force) { console.log("Aleady have that!" + octRequests[ix]); } - octantDict[octRequests[ix]] = - newStars[octRequests[ix]]; + octantDict[octRequests[ix]] = newStars[octRequests[ix]]; + totalStarDownloadCount += newStars[octRequests[ix]].length; + if (totalStarDownloadCount % 100 == 0) { + console.log('total stars loaded:', totalStarDownloadCount); + } } //console.log("Nodes: " + Object.keys(octantDict).length); visibleOctants = tmpVisibleOctants; diff --git a/thc/convert_tgas_to_csv.py b/thc/convert_tgas_to_csv.py index 4f36e46..1532bb3 100644 --- a/thc/convert_tgas_to_csv.py +++ b/thc/convert_tgas_to_csv.py @@ -3,13 +3,13 @@ import sys # Load stars from the HYG catalog. -hyg = {} -with open('../abbreviator/data/hygdata_v3.csv') as hyg_file: - reader = csv.DictReader(hyg_file) - for row in reader: - hip = row['hip'] - mag = float(row['mag']) - hyg[hip] = mag +#hyg = {} +#with open('../abbreviator/data/hygdata_v3.csv') as hyg_file: +# reader = csv.DictReader(hyg_file) +# for row in reader: +# hip = row['hip'] +# mag = float(row['mag']) +# hyg[hip] = mag def ConvertStar(row): hip = row['hip'] @@ -17,8 +17,8 @@ def ConvertStar(row): designation = '' if hip: designation = 'HIP ' + hip - if hip in hyg: - del hyg[hip] + #if hip in hyg: + # del hyg[hip] elif tyc: designation = 'TYC ' + tyc right_ascension = float(row['ra']) * math.pi / 180