Random Textures
Moderators: winston, another_commander
- Staer9
- ---- E L I T E ----
- Posts: 570
- Joined: Fri Feb 18, 2011 4:53 pm
- Location: Hatfield, Hertfordshire (poor industrial)
Random Textures
Is there any way of listing the testures in the shipdata.plist and it randomly selecting one of them?
I looked on the wiki and was unable to find anything about it, so I have decided to resort to the friendliest board this side of Riedquat
any help will be greatly apreiciated
I looked on the wiki and was unable to find anything about it, so I have decided to resort to the friendliest board this side of Riedquat
any help will be greatly apreiciated
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
Re: Random Textures
If you have several variants of a ship with different textures, and the same role, using that role will select one of the ships at random.
E-mail: [email protected]
Re: Random Textures
Or if you know the list of textures you want to chose from to apply to the ship you can change texture on-the-run using JS.
Via the setMaterials command. See also here for details of materials usage in the game.
A simple example is in my Butterlies demo oxp, although that changes the texture colour on the fly rather than the texture itself (although the principle is the same).
Via the setMaterials command. See also here for details of materials usage in the game.
A simple example is in my Butterlies demo oxp, although that changes the texture colour on the fly rather than the texture itself (although the principle is the same).
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- Staer9
- ---- E L I T E ----
- Posts: 570
- Joined: Fri Feb 18, 2011 4:53 pm
- Location: Hatfield, Hertfordshire (poor industrial)
Re: Random Textures
So just make a separate section in the Shipdata.plist for each one but give them all different textures?
is it easier just to make a template and then use likeship to duplicate it with different textures?
Thanks anyway.
is it easier just to make a template and then use likeship to duplicate it with different textures?
Thanks anyway.
- Commander McLane
- ---- E L I T E ----
- Posts: 9520
- Joined: Thu Dec 14, 2006 9:08 am
- Location: a Hacker Outpost in a moderately remote area
- Contact:
Re: Random Textures
Yes and yes.Staer9 wrote:So just make a separate section in the Shipdata.plist for each one but give them all different textures?
is it easier just to make a template and then use likeship to duplicate it with different textures?
- Staer9
- ---- E L I T E ----
- Posts: 570
- Joined: Fri Feb 18, 2011 4:53 pm
- Location: Hatfield, Hertfordshire (poor industrial)
Re: Random Textures
Well I have made it all now in 2 hours and 45 minutes the full shipdata.plist is finished using likeships and templates... however, like with most of my oxps there is a problem. before I changed the shipdata file it was fine, and yes I did hold down shift and when that didn't work I moved it out of the folder, started the game then put it back and restarted it. but it still didn't work which makes me think my programing skills are showing again.
is there an easy way of testing for errors in it or do I have to go through all 1148 lines of it?
<edit> oops, I just noticed that I forgot to include the:
}
on the end
<edit2> that didn't help... it still is refusing to work
is there an easy way of testing for errors in it or do I have to go through all 1148 lines of it?
<edit> oops, I just noticed that I forgot to include the:
}
on the end
<edit2> that didn't help... it still is refusing to work
- Okti
- ---- E L I T E ----
- Posts: 700
- Joined: Sun Sep 26, 2010 1:51 pm
- Location: A GH shop, near witchpoint to Oresrati in Galaxy 8
Re: Random Textures
Hi,
I am just trying to change the texture of a ship by setMaterials method. The code is below:
I am getting the log statements but the texture of the ship does not change. What I am doing wrong?
I am just trying to change the texture of a ship by setMaterials method. The code is below:
Code: Select all
this.shipSpawned = function()
{
this.mat = true;
this.materialTimer = new Timer(this,this.setMaterials1,0,5);
}
this.setMaterials1 = function()
{
if (this.mat == true)
{
log(this.name,this.mat);
log(this.name,"1");
this.ship.setMaterials({"texture1.png":{}});
this.mat = !this.mat;
}
else
{
log(this.name,this.mat);
log(this.name,"2");
this.ship.setMaterials({"texture2.png":{}});
this.mat = !this.mat;
}
}
- Commander McLane
- ---- E L I T E ----
- Posts: 9520
- Joined: Thu Dec 14, 2006 9:08 am
- Location: a Hacker Outpost in a moderately remote area
- Contact:
Re: Random Textures
The dumb question first: do the specified textures actually exist?
- Okti
- ---- E L I T E ----
- Posts: 700
- Joined: Sun Sep 26, 2010 1:51 pm
- Location: A GH shop, near witchpoint to Oresrati in Galaxy 8
Re: Random Textures
Yes they do, when I used to give them as a difuse_map they worked.Commander McLane wrote:The dumb question first: do the specified textures actually exist?
- Griff
- Oolite 2 Art Director
- Posts: 2482
- Joined: Fri Jul 14, 2006 12:29 pm
- Location: Probably hugging his Air Fryer
Re: Random Textures
I'm very likely reading your code wrongly but the wiki has the this.ship.setMaterials syntax as
it looks like in your code you're only listing the first texture (which should be the one referenced in your models .dat), try adding in the { diffuse_map: "texture2.png" } bit, eg
Code: Select all
this.ship.setMaterials({"my_ship_diffuse.png": { diffuse_map: "my_ship_damaged_diffuse.png" }});
Code: Select all
this.ship.setMaterials({"my_ship_diffuse.png": { diffuse_map: "texture2.png" }});
Wiki homepage for my OXP: http://wiki.alioth.net/index.php/Griff_Industries
- Okti
- ---- E L I T E ----
- Posts: 700
- Joined: Sun Sep 26, 2010 1:51 pm
- Location: A GH shop, near witchpoint to Oresrati in Galaxy 8
Re: Random Textures
Thanks Griff, diffuse_map or emission_map works fine. What I was trying to do was to change texture file completely to a new one. I don't know if it posible, if not I will use either one of the above.Griff wrote:I'm very likely reading your code wrongly but the wiki has the this.ship.setMaterials syntax asit looks like in your code you're only listing the first texture (which should be the one referenced in your models .dat), try adding in the { diffuse_map: "texture2.png" } bit, egCode: Select all
this.ship.setMaterials({"my_ship_diffuse.png": { diffuse_map: "my_ship_damaged_diffuse.png" }});
Code: Select all
this.ship.setMaterials({"my_ship_diffuse.png": { diffuse_map: "texture2.png" }});
Re: Random Textures
The "texture file" in the sense that I think you mean is the diffuse map. So if you set the diffuse map as Griff suggested, then you are essentially changing the texture. Unless of course you are using it as one of the other maps (emission or normal etc) then substitute the relevant map type in the command.
If by "texture file" you are meaning diffuse, emission and normal map, then you need to change the components individually. But for many ships the "texture file" is the diffuse map (possibly with others, but the diffuse is the main one).
If by "texture file" you are meaning diffuse, emission and normal map, then you need to change the components individually. But for many ships the "texture file" is the diffuse map (possibly with others, but the diffuse is the main one).
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- Okti
- ---- E L I T E ----
- Posts: 700
- Joined: Sun Sep 26, 2010 1:51 pm
- Location: A GH shop, near witchpoint to Oresrati in Galaxy 8
Re: Random Textures
Thanks Thargoid,
I am very new to Materials and textures used by oolite. I am trying to understand them.
Is the diffuse_map points to the texture file in the model.dat?
I am very new to Materials and textures used by oolite. I am trying to understand them.
Is the diffuse_map points to the texture file in the model.dat?
- Smivs
- Retired Assassin
- Posts: 8408
- Joined: Tue Feb 09, 2010 11:31 am
- Location: Lost in space
- Contact:
Re: Random Textures
That's right. The .dat specifies the diffuse_map. The materials can replace this and specifies other things like the emission_map and shininess and specular.
This example is from my shipset, which has a special Adder for the 'scavenger' role.
The standard Adder has this
The diffuse_map 'smivs'-adder.png' is specified in the .dat file.
If no materials were specified in the shipdata.plist, tha Adder (both varieties) would appear with just the 'smivs'-adder.png' texture but no emission_map or shininess/specular.
This example is from my shipset, which has a special Adder for the 'scavenger' role.
Code: Select all
materials =
{
"smivs'-adder.png" =
{
diffuse_map = "smivs'-adder-scavenger.png";
emission_map = "smivs'-adder_em-map.png";
shininess = 10;
specular_color = ( 0.3, 0.3, 0.3, 0.5 );
};
};
Code: Select all
materials =
{
"smivs'-adder.png" =
{
emission_map = "smivs'-adder_em-map.png";
shininess = 10;
specular_color = ( 0.3, 0.3, 0.3, 0.5 );
};
};
If no materials were specified in the shipdata.plist, tha Adder (both varieties) would appear with just the 'smivs'-adder.png' texture but no emission_map or shininess/specular.
Commander Smivs, the friendliest Gourd this side of Riedquat.
Re: Random Textures
The "xyz.png":{} is only the identifier for Oolite which material should be altered and must match the models material. It's usually (but not always) the same as the diffuse_map.