Posted: 16th Nov 2013 23:10
Hi Guys,

The attachment is a csv data file describing the location and brightness of 15448 stars. The original file was over 20 megs and contained lots of data about 119000 stars. I extracted only the brightest stars, of magnitude 7 or brighter.

The program uses a few functions from the Enhancements pack to access fields in the csv file. Naturally, you would have to edit the path shown in line 9 where I have "E:\TFF\shortlist.csv" to the path where you place the attached file.

All I do is create triangle objects whose size and brightness are based on the magnitude of each star. I only have it loading the first 5000 stars because creating 15000 objects is just too much for my system. It was taking over 30 seconds just to start up, but with 5000, it starts up in seconds. You can change the "for star =" loop to "5000 to 10000" or "10000 to 15000" to see other parts of the sky.

Its fun to scroll around on because the data is real and you will recognize some constellations pretty clearly. Orion is easy to spot. I have left & right arrow keys and page up and page down to scroll around and up & down arrow keys to zoom in and out. Q quits or just hit escape.

The point of this exercise was just to see if I could access the data and turn it into something recognizable. Next, I'd like to figure out how to set them up in a realistic 3d space. The original database has distance, colortype and all sorts of other data.

If you're interested the original 20 meg dataset can be downloaded here:
http://astronexus.com/files/downloads/hygxyz.csv.gz


+ Code Snippet
Rem Project: Astro
Rem Created: Thursday, November 14, 2013
Rem ***** Main Source File *****


	Separator$ = ","
	g = 60 : g2 = g/2
	      
	OPEN DATA FILE "E:\TFF\shortlist.csv", Separator$, 1
	rem   Stars = GET DATA FILE ROW COUNT( 1 )	

	For star = 1 to 5000
		MAG$ = GET DATA FILE CELL( 1, 1, star )	
		M = Val(MAG$)+2 : size = (8-M)*3
		C = Int(255-(M*40))    
		RA$ = GET DATA FILE CELL( 1, 2, star )
		DEC$ = GET DATA FILE CELL( 1, 3, star )
		x = -(val(ra$)*300)+800
		y = (val(dec$)*24)-250
		Make Object Triangle star,0,0,0,size,size,0,0,size,0 
		Color Object star,rgb(C,C,C)

		Position Object star,x,y,1500

	Next star
	CLOSE DATA FILE 1
	Make camera 1
	Backdrop on
	color backdrop 1,rgb(0,0,0)
 	Do 
 		If scancode() = 16 then exit
 		If scancode() = 203 then xa = xa - g
 		If scancode() = 205 then xa = xa + g
 		If scancode() = 201 then ya = ya + g2
 		If scancode() = 209 then ya = ya - g2
 		If scancode() = 200 then za = za + g
 		If scancode() = 208 then za = za - g 		
 		Position Camera 1,xa,ya,za
 		sync
 		winapi sleep 20			
 	loop
 	End	
	
Posted: 22nd Nov 2013 21:24
Sounds cool, but I don't have the enhancement functions.

Would you consider uploading an .EXE of this?
Posted: 23rd Nov 2013 1:37
Sure.

I just modified the code removing the path where I previously had the shortlist.csv file. Now, so long as they are in the same directory, the program should find the csv file.

Attached is the astro.exe and data file is still attached to the previous posting.
Posted: 23rd Nov 2013 2:34
By the way, you could rewrite it easily enough to avoid the functions of the enhancements pack. The csv file is just plain text so it could be read as strings by the regular dbpro functions and then separated by the commas, converted to values and so on. It would only be a little bit more cumbersome that way than it is now.
Posted: 19th Dec 2013 0:07
Hey what a great idea!!
Posted: 19th Dec 2013 2:20
To borrow from an idea that Lee's using - imposters. You could render your stars onto a skysphere (or skybox), save that to a file. Then have the same experience with only a minimal loading time or resource usage. You can create your skysphere, for example, to have as many surfaces (and hi-res textures) that you wanted to, if you wanted to keep the detail. If you're going to do that, you can use squares instead of triangles - it's only 1 more vertex (if you create them yourself instead of using the create plane command). One advantage you already have to rendering speed is that you have no need of texturing. So perhaps you could experiment with compressed textures or ones that use less bits, or that are alpha textures in front of a white background - see if anything speeds it up. The faster it renders, the less need you'll have to sacrifice resolution in your textures.

Edit:
Independent of this idea - you could speed up loading time by converting your table to a binary format, instead of text. Or better yet, if you create your meshes, then add them all to the same object, then just save your object.