I get a crash in ent_loacseconduvset(e3, e4), each mesh has 1870 faces.. any ideas?
Code:
var video_mode = 8;
plugindir = ".";
dllfunction ent_exportmesh(entity, filename);
dllfunction ent_importmesh(entity, filename);
dllfunction ent_loadseconduvset(entity1, entity2);
//----------------------------------------------------------------------------- mtl_lightmap
bmap bmap_lightmap = "lightmap.dds";
bmap bmap_plantlightmap = "tower_lightmap.dds";
material mtl_lightmap
{
skin1 = bmap_lightmap;
effect=
"
texture mtlSkin1;
texture entSkin1;
technique t0
{
pass p0
{
Texture[0]=<mtlSkin1>;
Texture[1]=<entSkin1>;
// mix light map with dynamic lighting
TexCoordIndex[0] = 1;
ColorArg1[0] = Texture;
ColorOp[0] = AddSigned;
ColorArg2[0] = Diffuse;
// apply lighting to texture
TexCoordIndex[1] = 0;
ColorArg1[1] = Texture;
ColorOp[1] = Modulate2x;
ColorArg2[1] = Current;
}
}
";
}
material mtl_plantlightmap
{
skin1 = bmap_plantlightmap;
effect=
"
texture mtlSkin1;
texture entSkin1;
technique t0
{
pass p0
{
Texture[0]=<mtlSkin1>;
Texture[1]=<entSkin1>;
// mix light map with dynamic lighting
TexCoordIndex[0] = 1;
ColorArg1[0] = Texture;
ColorOp[0] = AddSigned;
ColorArg2[0] = Diffuse;
// apply lighting to texture
TexCoordIndex[1] = 0;
ColorArg1[1] = Texture;
ColorOp[1] = Modulate2x;
ColorArg2[1] = Current;
}
}
";
}
//----------------------------------------------------------------------------- main
entity* e1;
entity* e2;
entity* e3;
entity* e4;
function main()
{
wait(3);
level_load("empty.wmb");
wait(1);
vec_set(sky_color, vector(250, 175, 75));
vec_set(sun_angle, vector(160, -35, 0));
sun_light = 20;
vec_set(camera.x, vector(300, 0, 200));
camera.pan = 180;
// // example 1
//
// load model with texture uv-set
e1 = ent_create("landscape.mdl", nullvector, 0);
e1.material = mtl_lightmap;
// load model with light map uv-set
e2 = ent_create("landscape_lm.mdl", nullvector, 0);
// generate and assign a new mesh with both uv-sets
ent_loadseconduvset(e1, e2);
ent_remove(e2);
// save mesh with both uv-sets for faster reuse
ent_exportmesh(e1, "landscape_lm.mesh");
////////////////////////
e3 = ent_create("plant.mdl", nullvector, 0);
e3.material = mtl_plantlightmap;
// load model with light map uv-set
e4 = ent_create("plant_lm.mdl", nullvector, 0);
// generate and assign a new mesh with both uv-sets
ent_loadseconduvset(e3, e4);
ent_remove(e4);
// save mesh with both uv-sets for faster reuse
ent_exportmesh(e3, "plant_lm.mesh");