Changing materials resets model scale

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2691
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Changing materials resets model scale

Post by spara »

I have scaled a subent down with model_scale_factor. Changing diffuse_map using setMaterials in a script resets the subent to the unscaled size. I probably should not do that.
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Changing materials resets model scale

Post by Smivs »

Did you mean 'it probably should not do that?' If so I agree.
Out of interest did you apply model_scale_factor to the sub-ent itself, or was it scaled down as a function of scaling down the model to which it is attached?
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2691
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Changing materials resets model scale

Post by spara »

Smivs wrote:
Did you mean 'it probably should not do that?' If so I agree.
Out of interest did you apply model_scale_factor to the sub-ent itself, or was it scaled down as a function of scaling down the model to which it is attached?
Yes, it should have been it :oops: . I applied the model_scale_factor to the subent itself and the mother was not scaled. Then I changed the material of the scaled subent and it changed to it's unscaled size.
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Changing materials resets model scale

Post by Smivs »

Did you sort this out?
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2691
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Changing materials resets model scale

Post by spara »

Smivs wrote:
Did you sort this out?
Sort of. It's for the Station Ads OXP. I use frame and screen subents that are attached to the dock entitity. And since my modeling skillz are quite non-existent on top of the fact Wings3D refuses to work correctly on my machine, I took some models from YAH and scaled them down in shipdata. All was fine until I changed the material on the screen subent and it switched to it's original size. Luckily the screen model is so simple, just a rectangle, that I could scale it down by hand by altering the vertex numbers in the dat file. So yes, I'm good for now, but this probably needs fixing anyway.
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Changing materials resets model scale

Post by Smivs »

Ah, OK, thanks. I'd guessed what you were doing :wink:
The reason I asked was because I was possibly considering a similar application in the future. I already have a scaled (in shipdata) model with sub-ents (the Cobra2 in X-ships) which has a scripted materials change but as far as I can see that is OK - I probably should go and check though.
Either way you are right that this should be fixed, as It clearly isn't right. Mind you it does open up some intriguing possibilities.... :D
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2691
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Changing materials resets model scale

Post by spara »

Smivs wrote:
Ah, OK, thanks. I'd guessed what you were doing :wink:
The reason I asked was because I was possibly considering a similar application in the future. I already have a scaled (in shipdata) model with sub-ents (the Cobra2 in X-ships) which has a scripted materials change but as far as I can see that is OK - I probably should go and check though.
Either way you are right that this should be fixed, as It clearly isn't right. Mind you it does open up some intriguing possibilities.... :D
I think it works if the whole model is scaled down, but if it's just a subent that has been scaled down then it seems to go wrong when materials change. And yes indeed, this scale factor is very nice property :D .
User avatar
Rorschachhamster
---- E L I T E ----
---- E L I T E ----
Posts: 274
Joined: Sun Aug 05, 2012 11:46 pm
Contact:

Re: Changing materials resets model scale

Post by Rorschachhamster »

This looks really nice. :D
And I'll just ask in this thread, because it is probably somehow related:
Any problems changing the diffuse_map on subentities via script? :wink:
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2691
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Changing materials resets model scale

Post by spara »

Rorschachhamster wrote:
This looks really nice. :D
And I'll just ask in this thread, because it is probably somehow related:
Any problems changing the diffuse_map on subentities via script? :wink:
No problem at all. Here's a snippet from Station Ads:

Code: Select all

...
var newAd = worldScripts["ad_resource"]._getHorizontalAd();
ship.subEntities[2].subEntities[3].setMaterials({"yah_griff_no_shader_screen.png": {diffuse_map: newAd, illumination_map: newAd, illumination_modulate_color: (127, 127, 127)}});
...
The script is attached to the station and the ad screen is a subent of the dock. So ship refers to the station, subEntities[2] refers to the third subent (dock in this case) of the station and subEntities[3] refers to the fourth subent of the dock.
User avatar
Rorschachhamster
---- E L I T E ----
---- E L I T E ----
Posts: 274
Joined: Sun Aug 05, 2012 11:46 pm
Contact:

Re: Changing materials resets model scale

Post by Rorschachhamster »

spara wrote:
Rorschachhamster wrote:
This looks really nice. :D
And I'll just ask in this thread, because it is probably somehow related:
Any problems changing the diffuse_map on subentities via script? :wink:
No problem at all. Here's a snippet from Station Ads:

Code: Select all

...
var newAd = worldScripts["ad_resource"]._getHorizontalAd();
ship.subEntities[2].subEntities[3].setMaterials({"yah_griff_no_shader_screen.png": {diffuse_map: newAd, illumination_map: newAd, illumination_modulate_color: (127, 127, 127)}});
...
The script is attached to the station and the ad screen is a subent of the dock. So ship refers to the station, subEntities[2] refers to the third subent (dock in this case) of the station and subEntities[3] refers to the fourth subent of the dock.
Ah! I tried to call a script directly from the subentity... :?
This will make it a lot easier, anyway. :lol:
User avatar
cbr
---- E L I T E ----
---- E L I T E ----
Posts: 1514
Joined: Thu Aug 27, 2015 4:24 pm

Re: Changing materials resets model scale

Post by cbr »

Does the scale_model work on subentities?
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2691
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Changing materials resets model scale

Post by spara »

cbr wrote:
Does the scale_model work on subentities?
Yes it does. That's the way things work in Station Ads.
User avatar
Amah
---- E L I T E ----
---- E L I T E ----
Posts: 486
Joined: Tue Aug 28, 2012 8:05 pm
Location: aboard the Laenina Crowne - Yasen-N class space freighter
Contact:

Re: Changing materials resets model scale

Post by Amah »

hmmh, it say in the wiki, iirc. Good to know.
Amah
Post Reply