Hi all,
I'm trying to set the Materials using entity.setSubMaterialName:
- Code: Select all
id = entity.spawn ( "crystal_mine", nLocX, 0.78, nLocZ, 0.012, 0.012, 0.012 );
sky.lprint("Original Material");
for i = 0, 4 do
j = entity.getMaterialName(id, i);
sky.lprint(j);
end
if ( playNo == 1 ) then
entity.setSubMaterialName ( id, 2, "crystals_b_adv" );
entity.setSubMaterialName ( id, 3, "sec_b_adv" );
entity.setSubMaterialName ( id, 4, "main_b_adv" );
elseif ( playNo == 2 ) then
entity.setSubMaterialName ( id, 2, "crystals_g_adv" );
entity.setSubMaterialName ( id, 3, "sec_g_adv" );
entity.setSubMaterialName ( id, 4, "main_g_adv" );
elseif ( playNo == 3 ) then
entity.setSubMaterialName ( id, 2, "crystals_r_adv" );
entity.setSubMaterialName ( id, 3, "sec_r_adv" );
entity.setSubMaterialName ( id, 4, "main_r_adv" );
elseif ( playNo == 4 ) then
entity.setSubMaterialName ( id, 2, "crystals_y_adv" );
entity.setSubMaterialName ( id, 3, "sec_y_adv" );
entity.setSubMaterialName ( id, 4, "main_y_adv" );
end
sky.lprint("");
sky.lprint("Changed Material");
for i = 0, 4 do
j = entity.getMaterialName(id, i);
sky.lprint(j);
end
Unfortunately, only the "crystals" actually change (see image):
The areas highlighted show up as BLACK, even though they seem to change (according to the log output)??
My main
.material file is as follows:
- Code: Select all
import * from "metal_sheet.material"
import * from "metal_plain.material"
import * from "main_b.material"
import * from "main_g.material"
import * from "main_r.material"
import * from "main_y.material"
import * from "sec_b.material"
import * from "sec_g.material"
import * from "sec_r.material"
import * from "sec_y.material"
import * from "crystals_b.material"
import * from "crystals_g.material"
import * from "crystals_r.material"
import * from "crystals_y.material"
material crm_mat_1 : metal_sheet
{
}
material crm_mat_1_adv : metal_sheet_adv
{
}
material crm_mat_1_deferred : metal_sheet_deferred
{
}
material crm_mat_2 : metal_plain
{
}
material crm_mat_2_adv : metal_plain_adv
{
}
material crm_mat_2_deferred : metal_plain_deferred
{
}
material crm_mat_3 : crystals_b
{
}
material crm_mat_3_adv : crystals_b_adv
{
}
material crm_mat_3_deferred : crystals_b_deferred
{
}
material crm_mat_4 : sec_b
{
}
material crm_mat_4_adv : sec_b_adv
{
}
material crm_mat_4_deferred : sec_b_deferred
{
}
material crm_mat_5 : main_b
{
}
material crm_mat_5_adv : main_b_adv
{
}
material crm_mat_5_deferred : main_b_deferred
{
}
main_g.material is like this:
- Code: Select all
import * from "Base_Multilight_V1.material"
import * from "Base_Multilight_V1_AlphaSmooth.material"
material main_g
{
technique
{
pass
{
ambient 0.5 0.5 0.5 1
diffuse 1 1 1 1
specular 1.53 1.53 1.53 1 22
emissive 0 0 0 0
texture_unit
{
texture green_main.dds
scale 1 1
}
}
}
}
material main_g_adv : Base_Multilight_V1
{
set $diffuseMap "green_main.dds"
set $normalMap "Blank_N.dds"
set $specularMap "white.bmp"
set $UV_Scale "1 1 0"
set $diffuse_tint_color "1 1 1 1"
set $rimlight_tint_color "1 1 1"
set $diffuseParam "1 0 0"
set $normalParam "0 1.5 0"
set $misc1 "1.53 22 0 1"
set $RimLight_Params "2.5 2.5 0.3 3"
set $LodDistance_0 "50"
set $UV_LodScale "1 1"
}
material main_g_deferred
{
technique
{
pass
{
diffuse 1 1 1 1
specular 1.53 1.53 1.53 1 22
texture_unit
{
texture "green_main.dds"
}
texture_unit NormalMap
{
texture "Blank_N.dds"
}
}
}
}
sec_g.material is:
- Code: Select all
import * from "Base_Multilight_V1.material"
import * from "Base_Multilight_V1_AlphaSmooth.material"
material sec_g
{
technique
{
pass
{
ambient 0.5 0.5 0.5 1
diffuse 1 1 1 1
specular 1.53 1.53 1.53 1 22
emissive 0 0 0 0
texture_unit
{
texture green_secondary.dds
scale 1 1
}
}
}
}
material sec_g_adv : Base_Multilight_V1
{
set $diffuseMap "green_secondary.dds"
set $normalMap "Blank_N.dds"
set $specularMap "black.dds"
set $UV_Scale "1 1 0"
set $diffuse_tint_color "1 1 1 1"
set $rimlight_tint_color "1 1 1"
set $diffuseParam "1 0 0"
set $normalParam "0 1.5 0"
set $misc1 "1.53 22 0 1"
set $RimLight_Params "2.5 2.5 0.3 3"
set $LodDistance_0 "50"
set $UV_LodScale "1 1"
}
material sec_g_deferred
{
technique
{
pass
{
diffuse 1 1 1 1
specular 1.53 1.53 1.53 1 22
texture_unit
{
texture "green_secondary.dds"
}
texture_unit NormalMap
{
texture "Blank_N.dds"
}
}
}
}
and finally,
crystals_g.material:
- Code: Select all
import * from "Base_Multilight_V1.material"
import * from "Base_Multilight_V1_AlphaSmooth.material"
import * from "Shadowmap_Depth1.material"
material crystals_g_ShadowCaster : Shadowmap_depth1_Caster_Alpha
{
set $diffuseMap "green_main_transparent_75.dds"
}
material crystals_g
{
technique
{
pass
{
ambient 0.5 0.5 0.5 1
diffuse 1 1 1 1
specular 1.53 1.53 1.53 1 22
emissive 0 0 0 0
texture_unit
{
texture green_main_transparent_75.dds
scale 1 1
}
}
}
}
material crystals_g_adv : Base_Multilight_V1_AlphaSmooth
{
set $diffuseMap "green_main_transparent_75.dds"
set $normalMap "Blank_N.dds"
set $specularMap "white.bmp"
set $UV_Scale "1 1 0"
set $diffuse_tint_color "1 1 1 1"
set $rimlight_tint_color "1 1 1"
set $diffuseParam "1 0 0"
set $normalParam "0 1.5 0"
set $misc1 "1.53 22 0 1"
set $RimLight_Params "2.5 2.5 0.3 3"
set $LodDistance_0 "50"
set $UV_LodScale "1 1"
set $shadowCasterMaterial "crystals_g_ShadowCaster"
}
material crystals_g_deferred
{
technique
{
pass
{
diffuse 1 1 1 1
specular 1.53 1.53 1.53 1 22
texture_unit
{
texture "green_main_transparent_75.dds"
}
texture_unit NormalMap
{
texture "Blank_N.dds"
}
}
}
}
Based on the above, I can't figure out why the "crystals" change colour, but the others come up as BLACK??
Any help would be greatly appreciated.
Regards
Shando
PS: forgot to mention that if I just change the crystals colour, the main and secondary colours show the correct default colours (so I assume it's not a normals issue?).
PS: Happy New Year to you all!