Alternative textures

General discussion for players of Oolite.

Moderators: winston, another_commander

Post Reply
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Alternative textures

Post by Smivs »

Hi all, silly question maybe, but is it possible within the shipdata.plist to call on more than one texture for a ship?
What I mean is, say I have a red version, a blue and a green version of the same texture, is there a simple way of calling them at random to get a bit of variety?
I've tried something like this

Code: Select all

materials = 
		{ 
			"myship.png" = 
                                          { 
diffuse_map = "redtexture.png(0.3)" "bluetexture.png(0.3)" "greentexture.png(0.3)";
                                          };  
		};
		model = "myship_redux.dat";
where myship_redux.dat specifies myship.png as the default diffuse map.
But no suprises, it didn't work. I have tried various permutations, such as commas (,) after each one, and without the 'chance' element (the (0.3)) to no avail.
Am I trying to do the impossible here?
Commander Smivs, the friendliest Gourd this side of Riedquat.
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 »

Err, no, there's at least 3 different things that would break that plist...

You can achieve the desired result in 2 different ways:

The first is the .plist method - you define one ship (let's say you called it 'shipred', with one material. then you define 2 more like_ships, which are meant to be absolutely identical in all other respects:

Code: Select all

	"shipblue" =
	{
		like_ship = "shipred";
		materials={
                        "myship.png" ={ diffuse_map = "bluetexture.png"; }; 
                };
	};
	"shipgreen" =
	{
		like_ship = "shipred";
		materials={
                        "myship.png" ={ diffuse_map = "greentexture.png"; };
                };
	};
edit: oops, I typed the stuff in braindamaged mode earlier...

Since they're absolutely identical in all other respects, they'll all have a 1/3 chance of appearing in a given system. In any case, if you want to start modifying the relative likelihood of appearance you can only do it inside the role key.

The second method would be to have a ship script that retextures the ship randomly inside a this.shipSpawned event, but most people are more confortable with .plists
Last edited by Kaks on Thu Nov 11, 2010 9:05 pm, edited 1 time in total.
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Post by Smivs »

Thanks, Kaks.
Funnily enough that's exactly what I've just been trying...it's not working but now I can see why. Brilliant! :D
Commander Smivs, the friendliest Gourd this side of Riedquat.
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 »

Oops, I just noticed I made a silly mistake in my example code. It should now be ok... sorry about that!
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

To flesh-out Kaks' method, of using scripting to "dye" the ship different colours.

Download my Butterflies demo OXP - that does something along those lines when they are spawned. There are 9 different coloured butterflies in the game, all using a single texture (ok a pair of them, one for the body and one for the wings but you get what I mean). The script also changes their displayed name as an added little bonus.

They have an 0.1 weighted trader role, or you can spawn them via the JS console with role "butterflies_butterfly".
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Post by Smivs »

Kaks wrote:
Oops, I just noticed I made a silly mistake in my example code. It should now be ok... sorry about that!
Ah, I was using the 'diffuse_map' part and assumed that's why it wasn't working. :( I'll go and have a thorough look at it again...knowing me I've done something stoopid!

@Thargoid, thanks, I'll have a look, although js is not a strong point of mine.

Edit:- Yes, I'd done something stupid :oops: it's working fine now. Thanks.
Last edited by Smivs on Fri Nov 12, 2010 11:06 am, edited 1 time in total.
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

It's quite a simple script (ignore the lower bit about moving wings, that's just to make them flap). It uses the setMaterials command, which is the scripting equivalent of what Kaks describes above using the colour parameter which is passed to the function from the call in shipSpawned.
Post Reply