Deep Horizon - Systems (Thread Renamed)

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

Post Reply
User avatar
Cmd. Cheyd
---- E L I T E ----
---- E L I T E ----
Posts: 934
Joined: Tue Dec 16, 2008 2:52 pm
Location: Deep Horizon Industries Manufacturing & Research Site somewhere in G8...

Deep Horizon - Systems (Thread Renamed)

Post by Cmd. Cheyd »

Okay, I said I'd post about this, so here it is... I'm working on SysRedux 2.0 with permission from Kaks and Capt. Kev. The plan is to use 3 texture pools: one for main planets, one for added planets, and the last for moons.

Main Planets - There will be 40 textures in this pool, divided into 8 subcategories of 5 each. A texture will be chosen from the subcategory based upon the the system's economy, tech level, and radius. Each texture will be initially produced at 8k x 4k then rendered down to 4x2 or 2x1. Yes, I will make lower resolution textures available as alternative packs. I will probably just make the core code as one piece, and then give folks the choice as to the resolution they want to download. If the planets eventually support normal mapping, shaders, etc... I hope to include code for it.

Added Planets - This pool will consist of the 16 original Sys Redux 1.0 planet textures, and 4 original System Redux 1.0 added-planet textures. I will not be including shader / etc code on these, unless I end up replacing all 20 at some far-flung date in future.

Added Moons - This pool will consist of the 4 original System Redux 1.0 moon textures, and 6 new textures. Again, probably won't do shader code, but may... If I do, I'll be dropping the original 4 textures. Only really considering because they appear so close to the main planet body.

I'll try and edit this post to let folks know how progress is coming. I will admit now, it is slow going. Have a lot of RL issues that are pressing me for time.
================================================================

Coding of Primary Script: Only 1 major bug, that I know of, remaining til completion. There are a few ideas for "nice-ities" I'd like to add, but they are neither major nor required.

Texture #1 - 75% Complete with diffuse texture, 75% complete with Normal map, 100% Complete with specular (assuming I don't do something stupid in the diffuse to change it)

Texture #2 - 50% Complete with Diffuse

Texture #3 - 25% Complete with Diffuse

Texture #4 - 25% Complete with Diffuse

Texture #5 - 25% Complete with Diffuse

Textures #6+ - Idea stage. Basically 1 or 2 sentence summaries of what I want them to be. (Yes, they have concepts. Not just random art.)
Last edited by Cmd. Cheyd on Fri Jul 15, 2011 5:04 pm, edited 1 time in total.
User avatar
Cmd. Cheyd
---- E L I T E ----
---- E L I T E ----
Posts: 934
Joined: Tue Dec 16, 2008 2:52 pm
Location: Deep Horizon Industries Manufacturing & Research Site somewhere in G8...

Post by Cmd. Cheyd »

Okay, here's the code in question:

Code: Select all

this.buildAdditionArrays = function()
{
	// See if we can exit early.  No need to be in this if there's nothing to do.
	if(system.planets.length == 1) return;
	
	// Loop through all the planets and moons to divide them accordingly
	for(var i = 0;i<System.planets.length;i++)
	{
		//Presume it's a moon if it has no atmosphere
		if(!system.planets[i].hasAtmosphere) 
		{
			// Add the body to the Moons array
			addedMoons.push(system.planets[i]);
		}
		else
		{
			// Main planet textures are handled by another function
			if(!system.planets[i].isMainPlanet) 
			{
				// Add the body to the Planets array
				addedPlanets.push(system.planets[i]);
			}
		}
		log("System Redux 2.0","Globe #" + i + ": " + system.planets[i]);
	}
}
As you can see from the end, the last real part of it is just logging the system.planets array elements. This two parts are snippets of the code for actually texturing the added moons/planets.

Code: Select all

this.texturePlanets = function()
{
	// Have planets been added to the system - If not, no need to do anything here.
	if(addedPlanets.length == 0) return;
	
	// Okay, so we have added planets.  Clear the array of used Textures.  And set TextureID to zero.
	planetTextures = [];
	planetTextures.length = 0;
	var textureID = 0;

	// This section is for troubleshooting only.  Not for inclusion in final code.
	for(var v = 0;v<addedPlanets.length;v++)
	{
		log("System Redux 2.0","Planet #" + v + ": " + addedPlanets[v]);
	}

Code: Select all

this.textureMoons = function()
{
	// Have moons been added to the system - If not, no need to do anything here.
	if(addedMoons.length == 0) return;
	
	// Clear the array of used Textures.  And set TextureID to zero.
	moonTextures = [];
	moonTextures.length = 0;
	var textureID = 0;
	
	// This section is for troubleshooting only.  Not for inclusion in final code.
	for(var v = 0;v<addedMoons.length;v++)
	{
		log("System Redux 2.0","Moon #" + v + ": " + addedMoons[v]);
	}
Again, part of them is just there to log the elements of their respective arrays. With the code laid out, let me present the scenario and the logged results. I launch from main station into hyperspace to a new system. This system produces the following results:
[System Redux 2.0]: Globe #0: [Planet ID: 263 position: (0, 0, 503040) type: PLANET_TYPE_GREEN radius: 41.920km]
[System Redux 2.0]: Globe #1: [Planet ID: 333 position: (4.01946e+006, -299262, 713625) type: PLANET_TYPE_GREEN radius: 160.000km]
[System Redux 2.0]: Globe #2: [Planet ID: 334 position: (1.20508e+006, 3.07666e+006, 874880) type: PLANET_TYPE_GREEN radius: 110.000km]
[System Redux 2.0]: Globe #3: [Moon ID: 335 position: (30236.4, 77808.1, 434027) type: PLANET_TYPE_MOON radius: 7.000km]
[System Redux 2.0]: Globe #4: [Moon ID: 336 position: (63933.3, 62175, 578216) type: PLANET_TYPE_MOON radius: 8.000km]
[System Redux 2.0]: Globe #5: [Moon ID: 337 position: (-85538.4, -51273.1, 569808) type: PLANET_TYPE_MOON radius: 9.000km]
[System Redux 2.0]: Globe #6: [Moon ID: 338 position: (24890.4, -57836.8, 404949) type: PLANET_TYPE_MOON radius: 8.000km]
[System Redux 2.0]: Planet #0: [Planet ID: 333 position: (4.01946e+006, -299262, 713625) type: PLANET_TYPE_GREEN radius: 160.000km]
[System Redux 2.0]: Planet #1: [Planet ID: 334 position: (1.20508e+006, 3.07666e+006, 874880) type: PLANET_TYPE_GREEN radius: 110.000km]
[System Redux 2.0]: Moon #0: [Moon ID: 335 position: (30236.4, 77808.1, 434027) type: PLANET_TYPE_MOON radius: 7.000km]
[System Redux 2.0]: Moon #1: [Moon ID: 336 position: (63933.3, 62175, 578216) type: PLANET_TYPE_MOON radius: 8.000km]
[System Redux 2.0]: Moon #2: [Moon ID: 337 position: (-85538.4, -51273.1, 569808) type: PLANET_TYPE_MOON radius: 9.000km]
[System Redux 2.0]: Moon #3: [Moon ID: 338 position: (24890.4, -57836.8, 404949) type: PLANET_TYPE_MOON radius: 8.000km]
As you can see - there are 2 extra planets and 4 moons produced. Now, I hyperspace to another new system, then hyperspace BACK to this one. This time, the log shows the following:
[System Redux 2.0]: Globe #0: [Planet ID: 442 position: (0, 0, 503040) type: PLANET_TYPE_GREEN radius: 41.920km]
[System Redux 2.0]: Globe #1: [Planet ID: 495 position: (4.01946e+006, -299262, 713625) type: PLANET_TYPE_GREEN radius: 160.000km]
[System Redux 2.0]: Globe #2: [Planet ID: 496 position: (1.20508e+006, 3.07666e+006, 874880) type: PLANET_TYPE_GREEN radius: 110.000km]
[System Redux 2.0]: Globe #3: [Moon ID: 497 position: (30236.4, 77808.1, 434027) type: PLANET_TYPE_MOON radius: 7.000km]
[System Redux 2.0]: Globe #4: [Moon ID: 498 position: (63933.3, 62175, 578216) type: PLANET_TYPE_MOON radius: 8.000km]
[System Redux 2.0]: Globe #5: [Moon ID: 499 position: (-85538.4, -51273.1, 569808) type: PLANET_TYPE_MOON radius: 9.000km]
[System Redux 2.0]: Globe #6: [Moon ID: 500 position: (24890.4, -57836.8, 404949) type: PLANET_TYPE_MOON radius: 8.000km]
[System Redux 2.0]: Planet #0: [object Planet]
[System Redux 2.0]: Planet #1: [object Planet]
[System Redux 2.0]: Planet #2: [Planet ID: 0 position: (2.53411e+006, 3.13372e+006, 999307) type: PLANET_TYPE_GREEN radius: 160.000km]
[System Redux 2.0]: Planet #3: [Planet ID: 0 position: (-1.84567e+006, 2.74662e+006, 1.10539e+006) type: PLANET_TYPE_GREEN radius: 110.000km]
[System Redux 2.0]: Planet #4: [Planet ID: 495 position: (4.01946e+006, -299262, 713625) type: PLANET_TYPE_GREEN radius: 160.000km]
[System Redux 2.0]: Planet #5: [Planet ID: 496 position: (1.20508e+006, 3.07666e+006, 874880) type: PLANET_TYPE_GREEN radius: 110.000km]
[System Redux 2.0]: Moon #0: [object Planet]
[System Redux 2.0]: Moon #1: [object Planet]
[System Redux 2.0]: Moon #2: [object Planet]
[System Redux 2.0]: Moon #3: [object Planet]
[System Redux 2.0]: Moon #4: [Moon ID: 497 position: (30236.4, 77808.1, 434027) type: PLANET_TYPE_MOON radius: 7.000km]
[System Redux 2.0]: Moon #5: [Moon ID: 498 position: (63933.3, 62175, 578216) type: PLANET_TYPE_MOON radius: 8.000km]
[System Redux 2.0]: Moon #6: [Moon ID: 499 position: (-85538.4, -51273.1, 569808) type: PLANET_TYPE_MOON radius: 9.000km]
[System Redux 2.0]: Moon #7: [Moon ID: 500 position: (24890.4, -57836.8, 404949) type: PLANET_TYPE_MOON radius: 8.000km]
Why am I getting extra objects? This is massively throwing another section of code off. In the Planets array, I'm not only getting extra entries from [object Planet], but I'm also getting 2 additional PlanetID:0's.
User avatar
Cmd. Cheyd
---- E L I T E ----
---- E L I T E ----
Posts: 934
Joined: Tue Dec 16, 2008 2:52 pm
Location: Deep Horizon Industries Manufacturing & Research Site somewhere in G8...

Post by Cmd. Cheyd »

Been staring at this for 24 hours... Walked over to a friend's desk at work, showed him the code, and seeing it on his monitor must have done the trick... I found the problem in 2 seconds flat.

Code is working now (generally), but I found a different piece that isn't performing 100% to my satisfaction, so going to work on that before I call it good.
User avatar
pagroove
---- E L I T E ----
---- E L I T E ----
Posts: 3035
Joined: Wed Feb 21, 2007 11:52 pm
Location: On a famous planet

Post by pagroove »

Nice to see the project is still alive. If you need planets or textures I can also make one or two.

Greetings,
P.A. Groove
For P.A. Groove's music check
https://soundcloud.com/p-a-groove
Famous Planets v 2.7. (for Povray)
Image
https://bb.oolite.space/viewtopic.php?f=4&t=13709
User avatar
Cmd. Cheyd
---- E L I T E ----
---- E L I T E ----
Posts: 934
Joined: Tue Dec 16, 2008 2:52 pm
Location: Deep Horizon Industries Manufacturing & Research Site somewhere in G8...

Post by Cmd. Cheyd »

Re-wrote pretty much the whole script this weekend. It's a LOT better. With the help of Kaks and a few others in the Testing forum, I fixed the one bug I knew I had. I've added a whole slew of debug code that can be toggled on/off. The idea being if someone hits a problem, I can just have them set a few things to 'true', reproduce the problem, and send me the latest.log.

So, to test out the new debug code, I turned it all on, including a few options that really are for me alone. And in the process, found my pseudo-random number generator doesn't work as advertised. It's great if you just want 1-10. From what I just saw though, it's not producing numbers over 10, even though I fed it a range of 20.

So, until I figure that out, I'm still stuck in the code-portion of this OXP.
User avatar
Cmd. Cheyd
---- E L I T E ----
---- E L I T E ----
Posts: 934
Joined: Tue Dec 16, 2008 2:52 pm
Location: Deep Horizon Industries Manufacturing & Research Site somewhere in G8...

Post by Cmd. Cheyd »

WOOT!!! Problem solved. The function was working properly, I was just an idiot and missed a typo. I was asking for 20 unique elements but was feeding it a range of 10 integers to choose from. Okay, unless something leaps out at me, or someone makes a special request, it's on to artwork!!!!
User avatar
Cmd. Cheyd
---- E L I T E ----
---- E L I T E ----
Posts: 934
Joined: Tue Dec 16, 2008 2:52 pm
Location: Deep Horizon Industries Manufacturing & Research Site somewhere in G8...

Post by Cmd. Cheyd »

Okay, I need some help from the more experience scripters / OXP'ers here.

Part of my script is a generalized function that produces and returns an array of pseudo-random numbers. I pass it a starting seed, an upper and lower range limit, and the number of elements I want in the array. It returns to me an array of non-repeated, pseudo-random numbers.

I use this function an average of 5 times per hyperspace jump / station launch. It does the heaviest lifting of the various parts of my script. Problem is - It's slow. On a standard station launch with 3 additional planets, 4 moons, and manipulating 4 characteristics of the star - I'm producing 5 arrays, and have about a 3-5 second delay on launch.

Now, I admit I have a lot of "debug" code in this script, but even if I remove ALL of it, there's no significant speed improvement due to the way the debug code is done.

Can one of you take a look at this, see if you can either:
1) Help me speed up the existing function, or
2) Help me come up with a new algorithm / mechanism / forumla / widget for generating the pseudo-random number?

Code: Select all

this.generatePseudoArray = function(intSeed, intLower, intUpper, intSize) {
	if(debug == true && dbg_PseudoRandom_Generation == true) {
		log("System Redux 2.0","Array requested.  intSeed = " + intSeed + "    intLower = " + intLower + "    int Upper = " + intUpper + "    intSize = " + intSize + ".");
	}
	// Clear variables from any past iterations of the function
	var validResult = false;
	var genResult = 0;
	var workingResultSet = new Array ();
	var seedCount = 427038;
	var unusedSeed = true;
	workingResultSet = [];
	
	// Generate as many results as are asked for by intSize
	for(var q = 0;q < intSize;q++) {
		do {
			// Need Function or subsection that will eliminate known bad seeds
			do {
				if(badSeeds.indexOf(intSeed)!=-1) {
					intSeed = ((intSeed*(system.techLevel+23+(seedCount*(q+1)))/(seed+system.population+(system.mainPlanet.radius/1000))));
					if(debug == true && dbg_PseudoRandom_Generation == true) {
						log("System Redux 2.0","Bad seed encountered.  intSeed reset to: " + intSeed);
						if(dbg_PseudoRandom_Detailed == true) {
							for(i=0;i<badSeeds.length;i++) {
								log("System Redux 2.0","Bad seed element #" + i + "containts: " + badSeeds[i]);
							}
						}
					}
					unusedSeed = false;
					seedCount++;
				}
				else {
					unusedSeed = true;
					if(debug == true && dbg_PseudoRandom_Generation == true) {
						log("System Redux 2.0","Good seed passed into function.");
					}
				}
			}
			while(unusedSeed == false);
			// <--------------------------------------------------------------
			// Generate a new psuedo-random number
			var maxi = Math.pow(2,32);
			intSeed = (134775813 * (intSeed + 1)) % maxi;
			var num = (intSeed) / maxi;
			if(debug == true && dbg_PseudoRandom_Generation == true) {
				log("System Redux 2.0","Generated intSeed: " + intSeed);
				log("System Redux 2.0","Initial Num: " + num);
			}
			var range = intUpper - intLower;
			num *= range;
			num += intLower;
			genResult = Math.floor(num);
			if(debug == true && dbg_PseudoRandom_Generation == true) {
				log("System Redux 2.0","Num: " + num);
				log("System Redux 2.0","Range: " + range);
				log("System Redux 2.0","Output Num: " + genResult);
			}
			// <--------------------------------------------------------------
			badSeeds.push(intSeed);
			intSeed = ((intSeed*(system.techLevel+17+(seedCount*(genResult+1)))/(seed+system.population+(system.mainPlanet.radius/1000))));
			if(intSeed < 10) {
				intSeed *= 10000000;
				if(debug == true && dbg_PseudoRandom_Generation == true) {
					log("System Redux 2.0","Sub-10 intSeed Generated.   intSeed advanced to: " + intSeed);
				}
			}
			// Evaluate pseudo-random result
			if(genResult == 0 || workingResultSet.indexOf(genResult)!=-1) {
				seedCount++;
				validResult = false;
				if(debug == true && dbg_PseudoRandom_Generation == true) {
					log("System Redux 2.0","Bad or Zero Result Generated \(" + genResult + "\).  seedCount advanced to: " + seedCount + "  intSeed advanced to: " + intSeed);
				}
			}
			else {
				validResult = true;
			}
		}
			// <--------------------------------------------------------------
		// A valid result has been produced, add to the return set
		while(validResult == false);
		workingResultSet.push(genResult);
		if(debug == true && dbg_PseudoRandom_Generation == true) {
			log("System Redux 2.0","Valid Result Generated.  intSeed advanced to: " + intSeed);
		}
	}
	// Set a new general seed, and return the result set as output
	seed = (genResult * intSeed);
	if(debug == true && dbg_PseudoRandom_Generation == true) {
		log("System Redux 2.0","Array successfully created.  Seed advanced to: " + seed);
	}
	return workingResultSet;
}
Any help is appreciated guys. And if you need to see the whole script, I can post it as well.
User avatar
Cmd. Cheyd
---- E L I T E ----
---- E L I T E ----
Posts: 934
Joined: Tue Dec 16, 2008 2:52 pm
Location: Deep Horizon Industries Manufacturing & Research Site somewhere in G8...

Post by Cmd. Cheyd »

Just so folks don't think I'm blowing smoke, as I know this project has been in the works for a while, thought I'd post some screenshots...
Moon #8
Image

Rich Industrial #5 (Still WiP)
Image

Would anyone be able to give me a UV Map (Is that the right term?) the game uses for planets? You know, the unfolded wire-frame? I'd like to try to design the textures around the image folds. I adjusted the above using standard Polar Coordinates, but in-game, it's still puckering pretty bad. Photoshop CS4 can wrap textures around meshes (right term?) so I might be able to import the mesh into it and actually paint directly on the mesh.

If so, thanks in advance!
User avatar
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

..

Post by Lestradae »

Go, Cmd. Cheyd, go!

Very much looking forwards to this oxp ... "Gut Ding braucht Weile!"

(try and use Babelfish on that one)

:D

L
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Post by Kaks »

..or read immediately below: 'all good things take time' :P
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
overmage
Deadly
Deadly
Posts: 128
Joined: Mon Mar 23, 2009 6:55 pm

Post by overmage »

that moon looks mad. :twisted:
User avatar
Rustybolts
---- E L I T E ----
---- E L I T E ----
Posts: 293
Joined: Sun Jun 07, 2009 6:22 pm
Location: UK

Re: ..

Post by Rustybolts »

Lestradae wrote:
Go, Cmd. Cheyd, go!

Very much looking forwards to this oxp ... "Gut Ding braucht Weile!"

(try and use Babelfish on that one)

:D

L
Actually google translator had no problem translating using auto detect language setting
STE.+ Firefly/Dragonfly + BlackJacksbullion v.1.23 link below.
http://www.mediafire.com/?sharekey=ca16 ... f6e8ebb871
Image
User avatar
pagroove
---- E L I T E ----
---- E L I T E ----
Posts: 3035
Joined: Wed Feb 21, 2007 11:52 pm
Location: On a famous planet

Post by pagroove »

The 2nd one looks like a good Gas Giant.

Keep it up :D
For P.A. Groove's music check
https://soundcloud.com/p-a-groove
Famous Planets v 2.7. (for Povray)
Image
https://bb.oolite.space/viewtopic.php?f=4&t=13709
User avatar
Cmd. Cheyd
---- E L I T E ----
---- E L I T E ----
Posts: 934
Joined: Tue Dec 16, 2008 2:52 pm
Location: Deep Horizon Industries Manufacturing & Research Site somewhere in G8...

Post by Cmd. Cheyd »

Ignore that green moon. After getting some sleep and coming to my senses, that thing looks like crap. It's going into the rubbish bin.
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2483
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post by Griff »

don't bin it, it looks great! a forest moon like in return of the jedi! are the white bits clouds or snow?
Post Reply