supertrace plugin / second uv-set plugin

Posted By: ventilator

supertrace plugin / second uv-set plugin - 06/06/07 13:56

supertrace.zip ~ 500kb

it's a free plugin with a function called supertrace() which works with static models and can return the texture coordinates (of both uv-sets) of the hit location.

(to try out the example script extract the zip file to the directory with the mesh plugin demo.)



for example it is helpful if you use entities with light maps and want to figure out the light map color somewhere or for painting graffitis, blood splotches,... at certains locations.



...
and in case you didn't know it already: mesh_plugin_demo.zip ~ 5mb

this plugin makes it possible to use two uv-sets on your models. since the mdl7 format doesn't support two uv-sets, you will need two versions of your model. one with the first uv-set and one with the second uv-set. with the ent_loadseconduvset() function you can load the uvs of the second model into the second uv-set of the first model.



see this thread in the third party forum for more details: http://www.coniserver.net/ubbthreads/showflat.php/Cat/0/Number/755382/page/0/fpart/1/vc/1
Posted By: DavidLancaster

Re: supertrace plugin / second uv-set plugin - 06/06/07 14:48

Greatest contribution/plugin ever. *gives Ventilator 1.2 million kudos*
Posted By: Puppeteer

Re: supertrace plugin / second uv-set plugin - 06/06/07 14:58

I already gave him 5 stars ^^
Posted By: frazzle

Re: supertrace plugin / second uv-set plugin - 06/06/07 19:40

Quote:

Greatest contribution/plugin ever.




One of the best indeed, very helpfull

Cheers

Frazzle
Posted By: Anonymous

Re: supertrace plugin / second uv-set plugin - 06/06/07 20:31

very, very useful!

thanx very much, mercuryus
Posted By: xXxGuitar511

Re: supertrace plugin / second uv-set plugin - 06/06/07 20:46

So, theoretically, would it be possible to generate lightmaps using supertrace() ? Or is supertrace actually the other way around, as in it only returns coords from vec, not coords to vec.
Posted By: ventilator

Re: supertrace plugin / second uv-set plugin - 06/06/07 20:55

for generating light maps it's the other way around. there you already have the triangle and its uvs. you have to rasterize the triangle and convert each pixel's uv-coordinate to a 3d-coordinate and trace to the light from there. i think that's the easy part. the hard part is the algorithm which automatically creates a good uv-map.
Posted By: xXxGuitar511

Re: supertrace plugin / second uv-set plugin - 06/06/07 21:08

I'm not worried about creating a good UVMap (Yet ), I just want to make a 'lil program for generating lightmaps ingame. I can use the TGA code on the WIKI to save them to TGA files. I've already done this with a terrain for a school project, but terrains are easy
Posted By: ventilator

Re: supertrace plugin / second uv-set plugin - 06/07/07 18:27

if you already have the uv-map for the light map then it isn't much harder than doing it for terrains (med supports automatic atlas mapping now so this could be used for the uv-map).

i think basically you just need a triangle rasterization algorithm and you have to know how to use barycentric coordinates so you can get the 3d-coordinates of the rasterized pixels. both things aren't too difficult and you can find information about it with google.

you have to use lite-c because with it you have access to the mesh data. i posted an example in the lite-c forum a while ago.

an ingame light mapper would be nice!
Posted By: xXxGuitar511

Re: supertrace plugin / second uv-set plugin - 06/07/07 18:34

I've been avoiding light c, lol..

I should probably start digging into it this weekend...
Posted By: ventilator

Re: supertrace plugin / second uv-set plugin - 06/07/07 18:43

i forgot to transform the collision geometry for supertrace() so it did only work for entities at the level origin. please download again if you have an old version.
Posted By: ventilator

Re: supertrace plugin / second uv-set plugin - 06/08/07 00:41

i have experimented a bit with an ingame light mapper. (the uv-map got done in blender.)

the rasterizer seems to work nicely but i think there are precision problems with c_trace. there is no lighting equation just black and white pixels for now.
Posted By: JetpackMonkey

Re: supertrace plugin / second uv-set plugin - 06/08/07 01:40

wow ventilator
Posted By: xXxGuitar511

Re: supertrace plugin / second uv-set plugin - 06/08/07 05:29

I'm seriously considering jumping into light-c. It would be especially useful for my new portal project, as I could use classes instead of a mess of arrays

I might check it out tonight, but it's already 1:30am, so I won't get too far into it tonight...


BTW, your ingame lightmapper is inspiration for me! thanks...
Posted By: Pappenheimer

Re: supertrace plugin / second uv-set plugin - 06/08/07 20:57

Quote:

(the uv-map got done in blender.)




...so, the model was made in MED?
With the uv-maps for the tiling texture?
And the mdl didn't change the positions and numbers of the vertices after doing the procedure in blender to get the uv of the shadow texture?

I ask because I'm in hope that I don't have to change my modeler (MED) to get two identical mdls with different uvs.
Posted By: ventilator

Re: supertrace plugin / second uv-set plugin - 06/08/07 21:40

no, i quickly did the complete test model in blender but the latest MED (the free lite-c one) could have been used too since it can do automatic atlas mapping now.

with different uv-maps the number of vertices will be different in the directx meshes (not in most model formats) but this doesn't matter for my second uv-set plugin. it can handle that. only the positions of each vertex of the corresponding triangles have to be the same.

...
i did some more experiments with my ingame light mapper. i am not sure yet how much work it will be and if the achievable quality will be good enough (c_trace inaccuracies,...) but maybe this really could turn into a complete light mapping solution which offers a nicer workflow than: adjust lights in WED->map compiler->check lighting in engine->adjust lights in WED->...

<edit>my ingame light mapper now features automatic uv-map generation! you just have to load your level with your models and it automatically does the rest. no need for manually preparing light map uvs.

it seems to work quite ok already:





...but adding a gui for light editing and so on will be a lot of work and i don't know when i will have the time... it also still lacks proper lighting equations, support for different light types, global illumination (i have some ideas how this could work ), there still are a lot of inaccuracies to fix,...</edit>
Posted By: Pappenheimer

Re: supertrace plugin / second uv-set plugin - 06/08/07 21:54

Quote:

WED->map compiler->check lighting in engine->adjust lights in WED->...




Wow!

This seems to mean, that I can keep WEDidiMEDibling my things together as I used to, but with results I dreamed of for years!
Posted By: JibbSmart

Re: supertrace plugin / second uv-set plugin - 06/09/07 06:58

wow! this is extremely cool -- 6 stars
Posted By: Pappenheimer

Re: supertrace plugin / second uv-set plugin - 06/09/07 12:32

Quote:

my ingame light mapper now features automatic uv-map generation!




Bought! When do you send it to me?
Posted By: fogman

Re: supertrace plugin / second uv-set plugin - 06/09/07 13:58

I canīt find a smiley for my feelings... you are a hero.
Posted By: TWO

Re: supertrace plugin / second uv-set plugin - 06/09/07 14:10

Holy grail... nice one
Posted By: Thomas_Nitschke

Re: supertrace plugin / second uv-set plugin - 06/09/07 14:14

It seems I cannot rate you higher than this. Damn the forum software
Congratulations ventilator, this is really one of the greatest contributions ever seen around here.
Posted By: ventilator

Re: supertrace plugin / second uv-set plugin - 06/10/07 06:42

a small addition:



now it supports multiple lights and the lighting equation takes color and falloff into account. shadows can be enabled or disabled for lights (i always wanted this possibility in wed! it makes using fill lights much easier.).

looks quite promising so far. hopefully no problems i didn't think of will arise. it's a pity nobody started sooner with something like this.
Posted By: xXxGuitar511

Re: supertrace plugin / second uv-set plugin - 06/10/07 06:46

So this is all generated from WED? And it supports static lights? And can be generated from WED?

If this is all true, then you are truly the master. If not, your still the master, lol. That is, until I catch up with you
Posted By: ventilator

Re: supertrace plugin / second uv-set plugin - 06/10/07 06:54

no, it's not generated from WED. after loading the level the light maps get calculated in the engine.

i use entities (small sphere models - see the white dot above) for setting the lights and they could be placed in WED of course. i didn't find a good way to access the real WED lights per script.

in the engine you can change the light position and settings and let the light map update immediately but i didn't work on a light editor yet.

...
maybe i should start a new thread about the ingame light mapper since it is work in progress and not directly related to the two plugins of this thread.
Posted By: xXxGuitar511

Re: supertrace plugin / second uv-set plugin - 06/10/07 07:07

...Sounds like a good idea
Posted By: William

Re: supertrace plugin / second uv-set plugin - 06/11/07 01:44

Wow, this sounds great. Probably the best part is that it automatically generates the second uvmap(without having to export 2 models). I'm sure many users would find it extremely useful. Looking forward to purchasing it when done.
Posted By: DavidLancaster

Re: supertrace plugin / second uv-set plugin - 06/16/07 12:20

Hey Ventilator

I can get your script to work, but when I tried implementing it myself I got an error 'crash in bmap_getcolor'.

Any ideas? Thank you!

Code:

plugindir = ".";

//////////////////////////////
// supertrace
//////////////////////////////
dllfunction drawuvs(entity, &positionandscale, &color, alpha); // slow!
dllfunction tc_beginbuild();
dllfunction tc_addentity(entity);
dllfunction tc_endbuild();
dllfunction supertrace(&p0, &p1);
dllfunction bmap_getcolor(bitmap, &recolor, xx, yy); // much faster than pixel_for_bmap() (doesn't work with dds!)
var trace_uv1[3];
var trace_uv2[3];


//////////////////////////////
// mesh lightmapping
//////////////////////////////

dllfunction ent_loadseconduvset(entity1, entity2);
dllfunction ent_exportmesh(entity, filename);
dllfunction ent_importmesh(entity, filename);

material* tempmaterial;

bmap bmap_lightmap = "pingvillage_lm.tga";

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;
}
}
";
}

var color[3];
ACTION lightmapped_mesh {
my.scale_z *= 1.12;
my.nofog = on;
my.polygon = on;
my.unlit = on;
my.ambient = 80;

my.material = mtl_lightmap; // assign light map material
ent_importmesh(my, "pingvillage_lm.mesh"); // load and assign the previously saved mesh which contains both uv-sets


/* temp_ent = ent_create("pingvillage_lm.mdl", nullvector, 0); // load model with light map uv-set
ent_loadseconduvset(my,temp_ent); // generate and assign a new mesh with both uv-sets
ent_remove(temp_ent); // tempentity isn't needed anymore
ent_exportmesh(my,"pingvillage_lm.mesh"); // save mesh with both uv-sets for reuse */

tc_beginbuild();
tc_addentity(my);
tc_endbuild();

WHILE (1) {
WHILE (!player) { wait(1); }
temp_ent = ptr_for_handle(player.animated_attach);
you = supertrace(vector(player.x,player.y,player.z),vector(player.x,player.y,player.z - 4000));
// you = supertrace(vector(camera.x, camera.y, camera.z), vector(camera.x, camera.y, -10000));
if (you)
{
bmap_getcolor(bmap_lightmap, color, trace_uv2.x * 1024, trace_uv2.y * 1024);
temp_ent.light = on;
temp_ent.blue = color.blue;
temp_ent.green = color.green;
temp_ent.red = color.red;
}
wait(1);
}
}


Posted By: ventilator

Re: supertrace plugin / second uv-set plugin - 06/16/07 12:34

does your light map have an alpha channel? bmap_getcolor at the moment only works with 888 format but with alpha channel the format is 8888.
Posted By: DavidLancaster

Re: supertrace plugin / second uv-set plugin - 06/16/07 13:50

No it doesn't have an alpha channel, I get the 888 error if I give it one, it just bypasses that and gives me the crash error, same mesh works in your demo, I've played around with it all, can't seem to find a solution. Let me know if you have any ideas. Thank you!
Posted By: ventilator

Re: supertrace plugin / second uv-set plugin - 06/16/07 13:57

bmap_getcolor(bmap_lightmap, color, trace_uv2.x * 1024, trace_uv2.y * 1024);

is your light map 1024x1024 too? hm... not sure why it would crash though since it's supposed to show an error message if a pixel is outside of the image.

can you send me your example?

(of course you can also try to use pixel_for_bmap instead of bmap_getcolor but it will be slower because the bitmap has to be locked/unlocked all the time.)
Posted By: DavidLancaster

Re: supertrace plugin / second uv-set plugin - 06/16/07 13:59

draw uvs works

Then when I draw the cross hair after 'draw uvs', it works but snaps to the nearest vertice on the uvs, it doesn't smoothly go over everything.

When I use bmap_getcolor I get that error :S It must be something I'm scripting because it works fine in your demo.
Posted By: DavidLancaster

Re: supertrace plugin / second uv-set plugin - 06/16/07 14:00

It's an engine crash :S Error 1513
Posted By: ventilator

Re: supertrace plugin / second uv-set plugin - 06/16/07 17:01

Quote:

Then when I draw the cross hair after 'draw uvs', it works but snaps to the nearest vertice on the uvs, it doesn't smoothly go over everything.


this happened with the first released version of supertrace if the entity wasn't at 0,0,0 because i forgot to transform the collision geometry. a week ago i uploaded a new version. are you sure you use the newest version?
Posted By: JetpackMonkey

Re: supertrace plugin / second uv-set plugin - 06/16/07 17:49

Wait a sec... I'm confused.. so do I have to create my lightmaps in Maya/Blender/Giles anymore, or is it all done by the plugin? That.. can't be true.. (or? is it that insanely powerful???)

If not, which part does the plugin handle..?


Would this mean that I could build my levels with Maya/Obj Splitter and automaticaklly have the shadows made and everything in the engine?!
Thanks
Posted By: ventilator

Re: supertrace plugin / second uv-set plugin - 06/16/07 18:03

Quote:

do I have to create my lightmaps in Maya/Blender/Giles


yes, you still have to create them with an external tool.

sorry for the confusion. i shouldn't have posted anything about the ingame light mapper in this thread. that wasn't very wise. the ingame light mapper still is an experiment and i don't know yet if it will ever be production ready.
Posted By: JetpackMonkey

Re: supertrace plugin / second uv-set plugin - 06/16/07 18:35

Oh! okay, so then nothing changed in the art path that I am using with the second uv-set plugin then, right? Same process, with two models and using c-script to load the second mesh etc?
Posted By: ventilator

Re: supertrace plugin / second uv-set plugin - 06/16/07 18:45

yes, it's still the same.
Posted By: DavidLancaster

Re: supertrace plugin / second uv-set plugin - 06/17/07 00:26

Quote:

Quote:

Then when I draw the cross hair after 'draw uvs', it works but snaps to the nearest vertice on the uvs, it doesn't smoothly go over everything.


this happened with the first released version of supertrace if the entity wasn't at 0,0,0 because i forgot to transform the collision geometry. a week ago i uploaded a new version. are you sure you use the newest version?



heh....thank you that was my problem

So now I have a mesh level, with cool lighting, and the player's ambient changes when it steps into the shadow/sun. You're the greatest Ventilator!
Posted By: Xarthor

Re: supertrace plugin / second uv-set plugin - 06/27/07 09:25

While I find this second uv-map thing pretty cool, I was always wondering how to let models react in a simple way to the shadow on the terrain or model, whatsoever.

While taking a quick look in the wiki I stumbled across the following shader:
http://www.coniserver.net/wiki/index.php/Texture_projector

It's a texture projector, which seems to project the texture of a model on another model depending on the projector's position.

Now I asked myself if it is possible to use that shader to project the shadow map of the terrain/entity on to (e.g.) the player entity?
Has anyone ever tried to link thoses things?
Posted By: DavidLancaster

Re: supertrace plugin / second uv-set plugin - 09/23/07 00:18

The 'old' supertrace plugin wont work with A7's new vertex geometry, Ventilator has made a new one for A7 and I hope he will post a download soon

I'd wonder how to project a shadow like that too, sounds like a powerful tool
Posted By: HeelX

Re: supertrace plugin / second uv-set plugin - 09/23/07 11:44

You said this will work with static models. Do you mean static meshes imported into WED or models which don't move/are animated.
Posted By: picoder

Re: supertrace plugin / second uv-set plugin - 11/08/07 23:24

Quote:

The 'old' supertrace plugin wont work with A7's new vertex geometry, Ventilator has made a new one for A7 and I hope he will post a download soon

I'd wonder how to project a shadow like that too, sounds like a powerful tool




Could you upload A7 version of supertrace plugin, please?
Posted By: DavidLancaster

Re: supertrace plugin / second uv-set plugin - 11/09/07 00:20

Here she be:

If you click this link you are acknowledging that this is the greatest plugin ever!
Posted By: DavidLancaster

Re: supertrace plugin / second uv-set plugin - 11/09/07 00:28

Here's something small I've achieved with Ventilator's plugin:



Click this link
Now click this link
Then save the images to your pc, or somehow figure out a way to instantly transition between them and you can see just how amazing mesh lightmapping is and why I love this plugin so much and how cool Ventilator is for making it! If you use bsp it's going to eat your performance and you don't have the flexibility and ease of creativity with meshes

Another example:
Here
And here

Posted By: Pappenheimer

Re: supertrace plugin / second uv-set plugin - 11/09/07 02:20

Nice little village!

May I suggest some improvements?

Increase the contrast between light and shadow, it would look more like a warm sunny day.
You can set the values in the lightmapper to a warm reddish and yellowish colour for the sun and to a colder bluish color for the shadow.
And increase the contrast of the grass texture.

You seem to use a plain ground without slopes.
If you actually do so, it would be an easy way to 'connect' the walls better with the grass when blending the grass texture with the wall texture at the lower edge in a painting program.

Another hint, although I don't know how successful it would be in its results:
switch off the blur in the lightmapper, and adjust the regions where you need blur in the paint program.
Posted By: DavidLancaster

Re: supertrace plugin / second uv-set plugin - 11/09/07 11:41

Those are good suggestions Pappenheimer, thank you!
Posted By: Machinery_Frank

Re: supertrace plugin / second uv-set plugin - 11/09/07 13:28

If you dont mind my coments then I would like to add something as well:

Some edges have sharp shadow transitions. Some smoothing in the shadow baker could help to overcome this. It is obvious on tree-trunks and on the walls.

I also would like to have more contrasty lighting but then you need a more bright sky. For your grayish, cloudy sky your lighting setup is perfectly right. So it just depends on the mood you want to achieve.

Wish you much success with this promising project.
Posted By: Why_Do_I_Die

Re: supertrace plugin / second uv-set plugin - 11/09/07 14:16

That looks beautifull man , but , what do u need to do it ? I know theres the raytracer dll , but is there some type of tutorial for implementing it with what you did for lighting ? I dont really understand how i could use the supertrace dll to do the lighting for a scene , another qustion , would this work for dynamic lighting as well , or only static lights ? Info appreciated.
Posted By: Wicht

Re: supertrace plugin / second uv-set plugin - 11/09/07 14:33

Supertrace has nothing to do with "Lighting the Scene".
Do you know SCAN_TEXTURE in c_move?

Manual:
Quote:


SCAN_TEXTURE Used to give actors some kind of vision, by retrieving the texture name, flags, brightness and light color of the hit surface. Mutually exclusive with USE_BOX.
The predefined string tex_name and the variables tex_flag1..tex_flag8, tex_light, tex_color and tex_fog are modified according to the hit object (see below). If nothing was hit, tex_name and the other parameters are not set. The texture name can be used to check the kind of floor below an entity. Through the str_cmpi instruction the floor texture name can be determined and some different walking behavior can be set. Another possibility is using tex_light to make a player invisible for his enemies when he hides in the shadows.





If you use Ventilator's MeshPlugin to give your Models a second UV-Set (Lightmapping) then you can get the Pixelcolor under the Player with Supertrace.
Posted By: picoder

Re: supertrace plugin / second uv-set plugin - 11/09/07 15:59

Quote:

Here she be:

If you click this link you are acknowledging that this is the greatest plugin ever!




Thank you.
Posted By: D3D

Re: supertrace plugin / second uv-set plugin - 11/10/07 04:12

Did anyone tried the mesh.dll with A7 C-script or Lite-C? I'm not able to look at the demo with current engine beta. Crash without error. Maybe something changed, i'll try again with A7.0.6 later on. Thought I could ask perhaps someone knows!?
Posted By: ventilator

Re: supertrace plugin / second uv-set plugin - 11/10/07 04:39

this happens because of an engine bug with the error() function. unfortunately i use the error() function for outputting the demo message.

the error() function is supposed to show a message window but currently the message just gets written to the acknex.log and the engine closes immediately.

this should only happen with c-script and jcl will fix it. the release version of the plugin doesn't show a demo message (only real errors) so it shouldn't be a big problem in the meantime.
Posted By: D3D

Re: supertrace plugin / second uv-set plugin - 11/10/07 06:01

Ok i've read that post too. Anyways i've now tried to run with A6.60 Lite-C and there is a wdl file with the same name containing plugindir = "."; only it didn't worked. No crash or error message just the acknex window shows up.

Furthermore mesh.dll isn't working with A7.06.1 and 7.0.7.1/2/3 beta on my computer, either with Lite-C or C-Script. If I try to run the C-Script version the compiler doesn't understand what bmap is on this line -> Code:
bmap bmap_lightmap = "landscape_lm.dds";


When I try to run the Lite-C version with A7 stable or any of the beta I get the crash without error in the demo level using the full version of the dll. Is the mesh.dll compiled with VC2005 NET?

Another problem:

Tried to run the C-Script version against A6.60 Commercial, however there was a problem because on the A6 (old key.exe) license my full name is used and on A7 it's shortened. Strange, but on A6.60 Lite-C mesh.dll didn't present this message about "the mesh plugin isn't registered to you!" What should I do next?

Code:
/*
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 = ".";
*/

#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);
}
}


Posted By: ventilator

Re: supertrace plugin / second uv-set plugin - 11/10/07 06:44

i have sent you the a7 version. a6 and a7 (from 7.05.1 on) need different versions because of the different vertex format of the engine. do you also need it for a6?

you must not load mesh files created with the a6 plugin (maybe you used the a6 demo files?) with the a7 plugin. this will crash.

in lite-c you have to be careful about passing char* instead of the needed STRING*. this can also be a reason for a crash. "" in the source is char* and stupidly won't get converted automatically.

please try if one of these is the reason. i guess so because the plugin works without problems for me and for others.
Posted By: D3D

Re: supertrace plugin / second uv-set plugin - 11/10/07 06:49

No I don't need the plugin for A6, thought it would not mind to try if mesh.dll worked with that version and maybe give a clue why it's not working right now.

Also i'm just using the Lite-c script example you've posted to load the Meshdemo with the full version of the dll. I have all versions of A6 on a DVD using the old key.exe and not in trial mode to see if A6.60 would work, but it didn't.

Reading the post again, I think with using the A6 demo files you meant those that are inside the Meshdemo.zip posted above? Well in that case would I only have to save them again in A7 to get it working?
Posted By: ventilator

Re: supertrace plugin / second uv-set plugin - 11/10/07 06:57

mesh_plugin_demo_a7.zip
please download this demo and use the newest a7 engine. delete the mesh_demo_a7.dll and put your dll into the directory. then run examples_litec.c.

<edit>
Quote:

Reading the post again, I think with using the A6 demo files you meant those that are inside the Meshdemo.zip posted above? Well in that case would I only have to save them again in A7 to get it working?


yes! or download the a7 demo from the link above.
</edit>
Posted By: D3D

Re: supertrace plugin / second uv-set plugin - 11/10/07 07:02

Yeah all good now. Thanks a lot! Now on to learning Gile[s]
Posted By: Pappenheimer

Re: supertrace plugin / second uv-set plugin - 11/11/07 14:25

Another screenshot dedicated to ventilator and his efforts!

Made without anything but WED, MED, MED's Atlasmapping and his plugin:



It is not optimized. What I am trying is a fast way to complete a game for kids with a slightly modified code of Running Food.
Posted By: frazzle

Re: supertrace plugin / second uv-set plugin - 11/11/07 15:27

Can't say it enough, this is a great plugin !!
Btw, I hope you succeed in your project Pappenheimer

Cheers

Frazzle
© 2024 lite-C Forums