3 registered members (wandaluciaia, AndrewAMD, 1 invisible),
765
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: use a second uv-set on your models
[Re: JetpackMonkey]
#131546
07/11/07 11:12
07/11/07 11:12
|
Joined: May 2002
Posts: 7,441
ventilator
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2002
Posts: 7,441
|
Quote:
Actually the really hairy part is generating the c-script to load all the different _lm meshes and their bmaps.. can you think of a good strategy to automate that?
wouldn't this work with my example script which checks if the _lm files exist?
|
|
|
Re: use a second uv-set on your models
[Re: ventilator]
#131547
07/11/07 12:19
07/11/07 12:19
|
Joined: Nov 2004
Posts: 862 Australia
DavidLancaster
User
|
User
Joined: Nov 2004
Posts: 862
Australia
|
Quote:
Quote:
Actually the really hairy part is generating the c-script to load all the different _lm meshes and their bmaps.. can you think of a good strategy to automate that?
wouldn't this work with my example script which checks if the _lm files exists?
What about the memory leaks with creating the materials?
Is there any work arounds?
So...if I wanted to have say 5 levels, in each of my 5 levels I had a terrain mesh with a lightmap and I wanted to use the supertrace plugin. Would I have to have all 5 of those lightmaps loaded into memory at once? How would I go about having only 1 loaded into memory at a time?
|
|
|
Re: use a second uv-set on your models
[Re: DavidLancaster]
#131548
07/11/07 12:29
07/11/07 12:29
|
Joined: May 2002
Posts: 7,441
ventilator
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2002
Posts: 7,441
|
jcl has added a mtl_remove() function so if you correctly use mtl_remove() and bmap_remove() then there won't be a memory leak. materials are so small though that the memory leak probably wouldn't do any harm. caring for the bitmaps is more important. ... from the beta page: Quote:
The handedness of the binormal is now stored in the 4th tangent coordinate of every vertex. This avoids shader problems with mirrored coordinates.
because of this change the current plugin version won't work anymore with the next engine release. the registered users will get an updated version.
|
|
|
Re: use a second uv-set on your models
[Re: ventilator]
#131549
07/11/07 12:34
07/11/07 12:34
|
Joined: Nov 2003
Posts: 1,659 San Francisco
JetpackMonkey
Serious User
|
Serious User
Joined: Nov 2003
Posts: 1,659
San Francisco
|
Thanks, how silly of me to miss that, I have no idea how I didn't see it. You're right, that would absolutey be sufficient! I can write a MEL script to select each polymesh, auto-unwrap it, add a texture and bake a shadow map to it, save the whole file as myname_lm.mb, then execute a modified version of the splitter with an -lm flag, without building a wmb ilke you mentioned, so that each _lm mdl has the same number prefix and name as the regular mdls. I am confident that I can script that first part in MEL. In that case, a version of the splitter which adds the _lm suffix/doesn't build a wmb would do the trick! Would you mind adding that to the splitter, if it's not too much work? By the way, a little off-topic but I will mention it here in case you open up and work on the splitter.. could you add another feature? Because each object the splitter exports has a different numerical prefix to avoid conflict, it's difficult to make LOD for so many models.. a solution to this would be a lodgp_ prefix, an LOD group that works like regular groups (gp_) do already, but the level designer makes sure that the contents of each one have a models with the same name and appropriate numericial suffix (0-4) per normal LOD naming convention. Simply put, items in an lodgp_ would be in a normal group but not have that unique numerical prefix. Thanks for everything, your tools have changed and improved my workflow a million times over
|
|
|
Re: use a second uv-set on your models
[Re: JetpackMonkey]
#131550
07/11/07 14:01
07/11/07 14:01
|
Joined: May 2002
Posts: 7,441
ventilator
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2002
Posts: 7,441
|
here is the lite-c version of the example script in case anyone would like to run the plugin demo with lite-c. it should also work with the free lite-c edition. save it as examples_litec.c and also create the file examples_litec.wdl which contains the line: plugindir = "."; Code:
#include <acknex.h> #include <default.c>
void ent_loadseconduvset(ENTITY* entity1, ENTITY* entity2); void ent_exportmesh(ENTITY* entity, STRING* filename); void ent_importmesh(ENTITY* entity, STRING* filename);
ENTITY* skycube = { type = "skycube+6.tga"; flags2 = SKY | CUBE | VISIBLE; material = mat_sky; }
void applylightmaps(); ENTITY* tempentity;
//----------------------------------------------------------------------------- mtl_lightmap
BMAP* bmap_lightmap = "landscape_lm.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; } } "; }
//----------------------------------------------------------------------------- main void main() { video_mode = 8; vec_set(mat_sky.emissive_blue, vector(20,20,20)); // make sky a bit brighter wait(3); level_load(""); wait(1); vec_set(sky_color, vector(250, 175, 75)); vec_set(sun_angle, vector(-30, 35, 0)); sun_light = 10; vec_set(camera.x, vector(300, 0, 200)); camera.pan = 180; STRING* meshfilename = "landscape_lm.mesh"; /* //-------------------- example 1 you = ent_create("landscape.mdl", nullvector, 0); // load model with texture uv-set you.material = mtl_lightmap; // assign light map material tempentity = ent_create("landscape_lm.mdl", nullvector, 0); // load model with light map uv-set ent_loadseconduvset(you, tempentity); // generate and assign a new mesh with both uv-sets ent_remove(tempentity); // tempentity isn't needed anymore ent_exportmesh(you, meshfilename); // save mesh with both uv-sets for reuse */ //-------------------- example 2 // for very huge models ent_importmesh() probably is faster than ent_loadseconduvset(). // usually ent_loadseconduvset() should be fast enough though. if(you) {ent_remove(you);} you = ent_create("landscape.mdl", nullvector, 0); // load model with texture uv-set you.material = mtl_lightmap; // assign light map material ent_importmesh(you, meshfilename); // load and assign the previously saved mesh /* //-------------------- example 3 // applylightmaps() cycles through all entities in the level and applies a light map // if the two "_lm" files exist for the entity. if(you) {ent_remove(you);} ent_create("landscape.mdl", nullvector, 0); applylightmaps(); */ while(!key_any) {wait(1);} def_moveset(); // default camera movement }
//----------------------------------------------------------------------------- example 3
var file_exists(STRING* filename) { var filehandle; filehandle = file_open_read(filename); if(filehandle) { file_close(filehandle); return(1); } else { return(0); } }
STRING* tempstring1 = "#100"; STRING* tempstring2 = "#100"; MATERIAL* tempmaterial;
void applylightmaps() { you = ent_next(0); while(you != 0) { str_for_entfile(tempstring1, you); str_trunc(tempstring1, 4); str_cpy(tempstring2, tempstring1); str_cat(tempstring1, "_lm.mdl"); str_cat(tempstring2, "_lm.dds"); if(file_exists(tempstring1) && file_exists(tempstring2)) { you.material = mtl_create(); // they should be removed again when changing the level tempmaterial = you.material; tempmaterial.effect = mtl_lightmap.effect; tempmaterial.skin1 = bmap_create(tempstring2); // they should be removed again when changing the level tempentity = ent_create(tempstring1, nullvector, 0); ent_loadseconduvset(you, tempentity); ent_remove(tempentity); } you = ent_next(you); } }
|
|
|
Re: use a second uv-set on your models
[Re: ventilator]
#131551
07/11/07 14:07
07/11/07 14:07
|
Joined: May 2002
Posts: 7,441
ventilator
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2002
Posts: 7,441
|
Quote:
Would you mind adding that to the splitter, if it's not too much work? By the way, a little off-topic but I will mention it here in case you open up and work on the splitter.. could you add another feature? Because each object the splitter exports has a different numerical prefix to avoid conflict, it's difficult to make LOD for so many models.. a solution to this would be a lodgp_ prefix, an LOD group that works like regular groups (gp_) do already, but the level designer makes sure that the contents of each one have a models with the same name and appropriate numericial suffix (0-4) per normal LOD naming convention. Simply put, items in an lodgp_ would be in a normal group but not have that unique numerical prefix.
i will try to add the _lm option in the next days.
i am not sure if i understand the lod solution and if it would be easy to add but i will think about it.
|
|
|
Re: use a second uv-set on your models
[Re: ventilator]
#131552
07/11/07 14:21
07/11/07 14:21
|
Joined: Nov 2003
Posts: 1,659 San Francisco
JetpackMonkey
Serious User
|
Serious User
Joined: Nov 2003
Posts: 1,659
San Francisco
|
Quote:
Quote:
Would you mind adding that to the splitter, if it's not too much work? By the way, a little off-topic but I will mention it here in case you open up and work on the splitter.. could you add another feature? Because each object the splitter exports has a different numerical prefix to avoid conflict, it's difficult to make LOD for so many models.. a solution to this would be a lodgp_ prefix, an LOD group that works like regular groups (gp_) do already, but the level designer makes sure that the contents of each one have a models with the same name and appropriate numericial suffix (0-4) per normal LOD naming convention. Simply put, items in an lodgp_ would be in a normal group but not have that unique numerical prefix.
i will try to add the _lm option in the next days.
i am not sure if i understand the lod solution and if it would be easy to add but i will think about it.
thank yOU thank yOU!! Oh the lodgp_, it could just be like a regular group except it wouldn't put a number in front of its objects:
so a normal group like gp_amplifiers with the following objects amp1.mdl amp2.mdl amp3.mdl
normally exports like this, by adding that numeric prefix _234_amp1.mdl _235_amp2.mdl _236_amp3.mdl
but if it were in lodgp_amplifiers, I would manually create the reduced LOD files, and manually name the files with LOD numeric endings:
amp1_1.md amp1_2.mdl amp1_3.mdl amp1_4.mdl
When running the splitter, it would recognize the lodgp_ and give em all the same numeric prefix:
_234_amp1_1.mdl _234_amp1_2.mdl _234_amp1_3.mdl _234_amp1_4.mdl
Maybe there's a better solution tho?
|
|
|
|