[Plugin] Import von 2. UVMap / Import of 2nd UVMap

Posted By: maybenew

[Plugin] Import von 2. UVMap / Import of 2nd UVMap - 03/26/07 21:35

Hi!

Deutsch:
suche jemanden der ein kleines Plugin schreiben kann, das folgendes ermöglicht:
Dem 2ten Skin eines Modells eine UV-Map zuweisen, die vorher nach möglichkeit aus einer ASC-Datei importiert wurde.
Kann dafür eine Bezahlung bis 150 Euro bieten, je nach Arbeitsaufwand.
Bitte hier oder per PM melden!
Danke!

English:
I am looking for someone to write a small plugin to load a second set of UV coordinates from a file (ASC if possible) and apply it to the skin of a model!
I can offer payment up to 150 USD (depending on the amount of work this needs)!
Please write here if interested or PM me!

Bye,

Andreas Zeitler
Ice Bytes
Posted By: lostclimate

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/27/07 05:02

I would be very interested in this also, as it would be handy for some shaders were i dont want the same uvs as the original skinning, as the movement in the uvs, make wierd seams
Posted By: maybenew

PAID: really simple Plugin - 03/27/07 22:43

I think lots of people need it and find it useful!
I would agree on that the author is allowed to sell the plugin to any third party!
Posted By: PHeMoX

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/28/07 00:09

Lol, you're going to pay americans less than europeans?

Cheers
Posted By: maybenew

PAID: really simple Plugin - 03/28/07 00:17

oh, okay, you have a point!

Everybody gets payed 150 EUROS!

Come on people!
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/28/07 00:44

probably such a plugin is worth more than 150€ since it isn't THAT simple. not that it is extremely hard but i think it isn't just a matter of loading the second uv-set. if you want to use the second uv-set for light mapping then the whole mesh has to be restructured since the two uv-sets will have different seams and vertices will have to be duplicated where the seams are different.
Posted By: maybenew

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/28/07 01:25

hm, does indeed not sound that simple!

I need the second UV map for light maps... Is there no way to get this done plain and simple?
Posted By: xXxGuitar511

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/28/07 02:46

You could even do this in WDL if you wanted.

You could create a wdl script for saving and loading a uv map, using functions already available in 3dgs...
Posted By: khanoftruth

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/28/07 02:55

And save yourself the 150 Euros
Posted By: xXxGuitar511

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/28/07 03:02

(Manual)

vec_for_uv()
vec_to_uv()
ent_vertices()


example:
Code:

function SaveUV()
{
var i;
i = ent_vertices(my);
//
while(i > 0)
{
vec_for_uv(temp, my, i);
//
// save temp.x & temp.y to a file or an array[]
//
i -= 1;
}
}




If I actually finish this, do I still get $150 ?...
Posted By: maybenew

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/28/07 04:10

you would think it is that simple, wouldn't you?

but the whole point of this is to create/access a second set of UV coordinates!

example:
Skin 1, UV set 1, diffuse texture
Skin 2, UV set 2, shadow texture (lightmap)

this way you can use a different UV mapping for each of the both skins!

And THAT is the hard part! Perhaps I did not get it, but I don't think you can modify the UV coordinates for each skin seperately using C-script!

JCL said that the engine internally supports 3 different UV sets, but you can only access one with MED!
Posted By: xXxGuitar511

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/28/07 15:34

Oh, well thats a bit different. I thought you wanted to switch between UV mappings at runtime.

I see what your looking for now. I'm not sure if you have the access to do so though. Even with a plugin that could read an asc file and create a UV map from it, how would you apply it to the models (second) skin at rumtime?
Posted By: maybenew

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/28/07 16:23

ent_mesh
Posted By: PHeMoX

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/30/07 02:14

Quote:

I see what your looking for now. I'm not sure if you have the access to do so though. Even with a plugin that could read an asc file and create a UV map from it, how would you apply it to the models (second) skin at rumtime?




I don't think we have access to it, since isn't the second or third UV-set used for lightmapping within 3dgs?

Cheers
Posted By: maybenew

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/30/07 02:41

honestly I don't know exactly!
I caught some bits and pieces from JCL and some more technical oriented people!

as far as they say it is possible to access and modify the data within the mesh of a model using a plugin!
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/30/07 09:48

it is possible! it just isn't as simple as it first seems.

i guess someone with a lot of direct3d experience could do such a plugin in 2 or 3 days but these people are rare here on the forum and probably wouldn't like to work for ~5€/hour. i think i would be able to do it too but it would take me 2 or 3 weeks full time because i would have to read a lot and experiment a lot so it isn't worth it for me.
Posted By: mk_1

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/30/07 15:15

Depends on the payment
I'd join Andreas jobs offer because I'm in need of a second uv set as well.
Posted By: maybenew

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/30/07 22:44

I think the community would greatly benefit of such a plugin and the author would be able to sell more than one copy!

Perhaps people who are interested in such a plugin can offer additional payment. At some point it will be enough to attract some direct3d/c++ guru to code the thing!

My initial offer is 150 Euro.

(make an offer to be added to this price, the programmer will receive the sum of all offers)
Posted By: mk_1

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/31/07 10:16

+30

=180€
Posted By: Wicht

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/31/07 10:50

+30

=210€
Posted By: Machinery_Frank

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/31/07 10:52

+30 = 240 €
Posted By: ulf

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/31/07 11:05

you guys should explain exactely what and how you plan to work with this plugin, and what external tools you plan to use.
show an example of what could be done with a second uvmap, then more people would probably join paying for this.
but for the average noob it is not clear what one could do with this.

make it clear for everyone please.
Posted By: JetpackMonkey

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/31/07 11:15

I would also contribute something towards the production of this tool. Lightmaps on non-BSP entities are my dream come true.

Though is this necessary with the new ABT tree scene manager system and arbitrary level geometry? I am still not entirely clear on what the difference would be.

I guess perhaps if the MDL's are dynamic entities that move around, though then the lightmapping would not really change with the movement??
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/31/07 11:15

i thought some more about it...

loading the uvs from an asc file probably wouldn't work that well. it would be better and easier to create a simple custom format which supports two uv-sets and contains the whole mesh in the way direct3d needs it. the 3dgs plugin could be quite simple then since it only would have to replace the mesh of an entity. the majority of the work could be handled by a blender (for example) export script then.

Quote:

Though is this necessary with the new ABT tree scene manager system and arbitrary level geometry? I am still not entirely clear on what the difference would be.

I guess perhaps if the MDL's are dynamic entities that move around, though then the lightmapping would not really change with the movement??


i think such a plugin still could be useful then. for example you can't use lod with level geometry. so maybe models which can have light maps would make it possible to build bigger levels since you could use a kind of "chunked lod".
Posted By: Machinery_Frank

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/31/07 11:25

Here is an explanation:

The goal is something like that (or more complicated):


I made this scene only with models and rendered the light and shadows in Lightwave. After that I created a fixed function effect (some kind of a shader) to blend the shadows with the color textures.

You can find the 3dgs-scene here:
http://www.firma-geppert.de/Gamedev/Images/shadowmap.zip

But this is complicated. Every object needs an specific material and you cannot tile textures.

The goal of the second uv-set is:
1) you can use the first texture with texture-tiling. So you can use a wood-texture for the chairs and you can map the top and bottom sides of the seat-plate to the same texture space. You can create very detailled color uv-mapping.

2) the shadow map gets another uv-map. Here is no tiling / no repetitions. So it can contain the shadows for every surface of the object. It has not a very high resolution but that is okay for shadows.

I hope this makes it a bit more clear.
Posted By: Wicht

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/31/07 11:33

Export two Models from your Modeler. The first Model with the uv-map you need for the colormap. The second model with the uv-map you need for the lightmap.

Open the second model in MED. In the Skineditor go to Export->SkinMapping. Then you have your second uv-map available in a text-file.

What you need? The posibility to import this text-file as second uvmap in the first model.
Posted By: maybenew

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/31/07 13:40

Franks explanation of the goal of this hole thing is very good!
This plugin would make things a lot easier!

Here is another example how the plugin will be used or what it can do:


the light-mapped scene in the second screenshot is achieved by creating a second model with the lightmap UV coordinates and the lightmap texture, placing it in the excact location of the texture model and using a shader to blend both models together... it is awfully complicated and any game programmer will kill you the for doing this in the same way this method kills the performance!

With the plugin it will simply be: one model with 2 uv maps + texture + light map.

concerning the approach of actually saving the second UV map my idea is the same as Wichts:
You have a second copy of the model imported to MED which uses the Lightmap-UVs and you use the export function to export the UV coords to a file! now you can use the plugin to append this second set of UV coordinates to the first model.

I think ventilators idea is not that bad!
The models with lightmaps would most likely be used to replace level geometry, therefore the models won't need to have animations or bones! A own model format therefore only has to include mesh and UV coordinates, skins can be loaded from external sources!

I would make it an even 250 Euros!
Ventilator, willing to give it a try?
Posted By: JetpackMonkey

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/31/07 14:48


Quote:

geometry. so maybe models which can have light maps would make it possible to build bigger levels since you could use a kind of "chunked lod".




Ah! Fantastic then.. I know that the GTA III series used polymesh pieces with LOD and lightmaps like that, instead of BSP or Octree.

Wow. I will pitch in at least 20 euros if anyone develops this plugin as well and more if I can afford it. Maybe some other people here can also offer to pitch in towards such a tool development.

So would the lightmaps would then be generated in giles/lightwave/max/maya etc?
Posted By: Excessus

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/31/07 16:23

Quote:

not that it is extremely hard but i think it isn't just a matter of loading the second uv-set. if you want to use the second uv-set for light mapping then the whole mesh has to be restructured since the two uv-sets will have different seams and vertices will have to be duplicated where the seams are different.



I'm curious about this, but I know very little about the way meshes are stored.. Why would the mesh be affected in any way by the UV map? Wouldn't it just be a matter of saving 3 more skin points for every triangle declaration?

Also, does the mdl7 format support multiple UV maps at all, or is it just the engine? In other words, could the second UV map be stored in the mdl file, or should it be loaded at runtime? I looked at the mdl7 SDK and the function for saving a triangle looks like this:
Code:
bool Triangle(int v1, int v2, int v3, int sp1, int sp2, int sp3, int material = -1);


3 vertex indices and 3 skin point indices. This looks like you can only save 1 texcoord for every vertex in a .mdl file..
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/31/07 16:57

direct3d meshes don't work like the mdl7 format. the reason the mesh gets affected is because uvs get stored with a vertex in the vertex struct and not separately. in a modeling program a vertex can have several different uvs if it is at an uv-seam. in the direct3d vertex buffer such vertices have to be stored multiple times so that each uv is there. this duplication will affect the triangle indices of course.

so you have to write an algorithm which finds out which vertices have to be duplicated and then generate the proper vertex and triangle lists. if i did this in python like i talked about in my previous post this wouldn't be the hard part anymore.

now the hard part for me is all the direct3d buffer stuff since i have no experience with that and i find it a bit confusing. i will try to experiment a little in the next days.

...

the mdl7 format doesn't support a second uv-set.
Posted By: broozar

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/31/07 18:34

ahm... just to your info: this is exactly what the static mesh support in a7 is supposed to do. so if you wait some months, you#ll get it with a7.

the greatest disadvantage would be that the shadows are only baked, move the chair in franks example and the scene will look odd. so this metod would only be good for an unchanging lighting situation in combination with immovable objects. rather limited, if you ask me.
Posted By: Excessus

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/31/07 18:59

I think external modelling applications will always do a better job at lighting a scene than WED. For example WED shadows don't have realistic penumbrae.

Quote:

the greatest disadvantage would be that the shadows are only baked, move the chair in franks example and the scene will look odd. so this metod would only be good for an unchanging lighting situation in combination with immovable objects. rather limited, if you ask me.



The same goes for the upcoming static mesh support, exept that static meshes truely CAN'T be moved.
Posted By: Excessus

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/31/07 21:13

Ok everyone! Good news!

I dived into D3D and it's really not all that hard

I have found a way to do this and maybe I can release a rough plugin as soon as tomorow. A touched up version should be done at the end of the next weekend. I have exams next week, so I can't work on this during the week..

What I've got now:
A plugin that can copy the normal UV Map to the second UV map. I can test this with two small shaders that use either TEXCOORD0 or TEXCOORD1 for texture lookup. When I launch my app, the warlock looks normal with the TEXCOORD0 shader, and messed up with the TEXCOORD1 shader. If I call my plugin function, the TEXCOORD1 shader will look correct (because the TEXCOORD0 was copied there).

So the only thing left to do is write a function that can read in the UV coord, instead of copying the first UV.. I hope the skin points exported by 'export skin mapping' in MED are in the right order, or I will have to come up with something clever..

@Ventilator: the vertex format used by 3DGS already has 3(!) texture coords per vertex, thus no need to duplicate vertices.

EDIT: could someone (frank?) send me a model with 2 UV maps and a shadow map? You could send one .mdl with a normal diffuse texture and the normal skin mapping, and another one with the shadowmap and different UV mapping. My email is taco dot cohen at gmail dot com.
Posted By: Machinery_Frank

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/31/07 21:35

Thanks for looking into that!
Posted By: JetpackMonkey

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/31/07 22:28

brilliant! Very exciting news, Taco
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 03/31/07 22:55

Quote:

@Ventilator: the vertex format used by 3DGS already has 3(!) texture coords per vertex, thus no need to duplicate vertices.


yes, there are 3 texture coordinates in the vertex struct but this doesn't solve the problem in any way. you will notice it once you get real model data to play with. if the seams of the first uv-set and the seams of the second uv-set aren't the same then you will have to duplicate vertices. for light maps with their automatic atlas mapping they very likely won't be the same.

<edit>
with seams i mean the borders of the uv-patches. look at maybenew's example or here:



the light map uvs on the right have a lot more seams/borders. in this example the mesh has 24 vertices, the texture uv-map has 24 uv-vertices (but this is just a coincidence - most of the time the number won't be the same) and the light map uv-map has 72 uv-vertices if i counted them correctly. so how will you store them in a vertex buffer which contains only 24 vertices? you need to duplicate the vertices correctly!
</edit>

but it would be nice if you could post your source code so far since my first tries showed that i seem to be too stupid even for the most basic direct3d buffer stuff. maybe some of my problems are related to lite-c though. for example d3d9.h doesn't seem to be very complete.
Posted By: Excessus

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/01/07 06:12

I knew it couldn't be that easy or someone would have done it !

So I understand the core of the problem now: a vertex can have multiple skin points, even on a single UVmap. Ofcourse..

I wonder, though.. If you where to edit the mesh, breaking vertices everywhere, wouldn't that affect the shading? When a vertex (in 3D space, not on the UV) is duplicated its normal cannot be interpolated and you will get 'flat shading'. Maybe this just isn't a problem when all the lighting is in the skin anyway?

I looked in the sampledll and it uses d3dx9.h not d3d9.h. This file is included in the directX SDK, which you can download from microsoft. The code I have so far (quick and dirty without much error handling):
Code:

DLLFUNC var assignUV(ENTITY* ent)
{
if (!ent) return 0;

LPD3DXMESH entMesh = (LPD3DXMESH)ent_mesh(ent, 0);
int numVertices = _INT(ent_vertices(ent));

VERTEX* pVerts = NULL;
entMesh->LockVertexBuffer(0, reinterpret_cast<void**> (&pVerts));

for(int i = 0; i < numVertices; i++)
{
//pVerts[i].tu2 = pVerts[i].tu1; // Copy v1 to v2
//pVerts[i].tv2 = pVerts[i].tv1;
//pVerts[i].tu1 = 0.0f;
//pVerts[i].tv1 = 0.0f;

pVerts[i].tu2 = 0.0f; // alternative: empty v2 (seems to contain v1 usually)
pVerts[i].tv2 = 0.0f;

}

entMesh->UnlockVertexBuffer();
return _VAR(1);

}



pVerts is just a pointer, so using [] translates to pointer arithmetic. It's the same as &(pVerts + i), it moves the pointer ahead i * sizeof(VERTEX) each time (sorry if you knew this, I have no idea of your C++ skill but I thought this was pretty smart ).
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/01/07 11:52

the vertex struct also contains the normal. the normals of broken vertices could all point in the same direction so shading shouldn't get affected. but there are cases when the normals get recalculated (ent_fixnormals(),...) and i am not sure how this could get handled. maybe there is some other additional buffer which contains information about which broken vertices should be handled as a single vertex.

thanks for posting your example! i think i understand how arrays and pointers relate to each other but a reminder is always good since i still sometimes make mistakes with it.

my example from yesterday looks similar. not sure what's wrong with it but i will experiment...
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/02/07 14:55

Quote:

[...] pVerts is just a pointer, so using [] translates to pointer arithmetic. It's the same as &(pVerts + i), [...]


don't you mean *(pVerts + 1) instead of &(pVerts + 1)?

darn, i still didn't succeed in getting my example working in lite-c.
Posted By: Excessus

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/03/07 14:05

Quote:

don't you mean *(pVerts + 1) instead of &(pVerts + 1)?



Oh yea, ofcourse. As you can see I'm still sometimes making errors with pointers aswell.

Have you tried to copy/paste my code in lite-c? I don't know what the problem could be as I've not used lite-c extensively yet. My code doesn't use any C++ specific constructs, so you should be able to use it in lite-c aswell (maybe remove the type conversion macros).

Do you need this for your newton plugin, or for this plugin? Are you planning on doing this plugin, once you get the hang of d3d? I've given the algorithm some thought and I must admit it hurts my brain.
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/03/07 14:47

Quote:

Have you tried to copy/paste my code in lite-c? I don't know what the problem could be as I've not used lite-c extensively yet. My code doesn't use any C++ specific constructs, so you should be able to use it in lite-c aswell (maybe remove the type conversion macros).


yes, i tried your version. my version and your version seem to give me the same wrong results in lite-c.

how does your VERTEX struct look like?

Quote:

Do you need this for your newton plugin, or for this plugin?


it's needed for both. printing out the mesh will be helpful for debugging and almost the same code will be usable for feeding the geometry to newton for collision detection.

(and i have another idea where this would come in handy. for machinima projects i always wanted to create a plugin which allows you to record gameplay and then render a high quality version from it using a renderer like yafray or gelato. )

Quote:

Are you planning on doing this plugin, once you get the hang of d3d? I've given the algorithm some thought and I must admit it hurts my brain.


i would do it if i got this d3d stuff working but i am not sure when and if this will happen. maybe i should better try to use a c++ compiler but i can't download the huge directx sdk with my crappy internet connection.

the algorithm isn't tricky. basically you just have to iterate through all triangles and put each vertex (with its position, normal, uv1, uv2 data) of a triangle into a python dictionary (called hash table or map in other languages i think?). to build the index list you can lookup the vertices in the dictionary then.

...

i think simply loading the second uv-set from an exported med txt file won't work since with that format you won't know which uvs and which vertices belong together for light maps.

so like i already said i would do a complete mesh loader which replaces the mesh of an entity. another problem came to my mind now though. such a mesh loader would also have to care about loading textures which makes it more complicated. or the entity which gets the mesh replaced would already need to have the correct textures applied but this would be a kind of ugly solution since there always would be the need for two versions of the model (mdl7 + custom format) then.
Posted By: maybenew

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/03/07 15:39

Sounds complicated! Perhaps you can JCLs input on the matter. According to him it should not be this difficult to achieve the function we all need.
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/03/07 15:57

it isn't simpler than i described it. i have discussed this with jcl (in a future forum thread from august). his very simple solution he always comes up with is useless with "real world" models and he admits that it is more complicated later in the thread.
Posted By: William

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/04/07 14:02

Before I knew of the FBX importing/Arbitrary Geometry of 3dgs future, I looked into this a fair amount. I was always told mostly that it would require a new model format for 3dgs(and would cost a fair amount due to that).

Though, if someone manages to get this working, then I'm willing to chip in 150 euros. I'm using Max, and prolly have a similar max2mdl workflow as mabyenew. I'll probably end up using the new FBX importer(I'm waiting for JCL to first add the ability to place models in WED with it too) and WED lighting anyways, but more options never hurt. I think those with projects demanding realistic lighting would really find it useful though.
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/04/07 21:57

it was a stupid lite-c quirk. i am a bit further now. i also have some new ideas and if i didn't overlook anything i think i will be able to do it. probably i will need some help from jcl though once he is back.

some example mdl7 models would be helpful. once with normal uvs and once with light map uvs.
Posted By: William

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/05/07 03:08

How is this gonna work for a 80-100 model scene? Is the user going to have to export 2 models for every model in the scene? Afterwards, would the code just be able to red the uvcoords thru a script? I think the workflow would be very hampered if you have to go into MED to get the uvcoordinates for every model... maybe have the models used for retrieving uv coords have a special tag in front of them, like "uv_chair.mdl". When the script runs it takes "chair.mdl" for the base, grabs the extra coords from a model with "uv_" in front of the original model name, then applies it. If the "uv_" model doesn't exist, then it just uses the original uv parameters for both texture 1 and 2.

I ask this question because workflow is one of the most important aspects of developing a game. The typical workflow I use for a level goes something like this:

Create scene in Max.

Export Scenes models into a folder with Max2MDL.

Export models positions via Max2GS.

Build in WED.

If one were to use a second uv set. Mabye like this:

Create scene in Max. Bake lighting into a separate Map Channel.

Export Scenes models into a folder with Max2MDL using map channel #1.

Export Scenes models into a folder meant to hold uv models only, only this time using map channel #2.

Export models positions via Max2GS.

Build in WED.

Let the script do the rest of the work, without having to use MED.

I'm not sure how mabyenew would go about this, i'm interested if theres anyway to speed up the changing everything to map channel #2 in max part?
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/05/07 04:06

using med uv-export like maybenew suggested wouldn't work anyway.

if everything works out i will create a c-script+python tool which reads the two model files and generates the txt file the plugin will require. so you could script your own batch job in any way you want.

before i continue i will probably have to wait for jcl though since i have some questions...

does anyone know if the directx9 sdk from summer 2004 will still be useable? i will have to switch from lite-c to c/c++ sooner or later.
Posted By: Excessus

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/06/07 14:03

Quote:

does anyone know if the directx9 sdk from summer 2004 will still be useable? i will have to switch from lite-c to c/c++ sooner or later.



I just checked, and it contains DirectX9.0c, so I guess it should work. Do you have a copy of it lying around? If you have to download it anyway, why not download the latest SDK (february 2007)?

BTW, wouldn't it be easyer to use an already existing format that supports 2 UV maps to load the models from? So instead of exporting to mdl, you'd just export to something else. That way the workflow would be optimal. Does .x allow multiple UVs? What about .fbx?
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/06/07 15:05

the summer 2004 sdk worked! i have a monthly bandwidth limit and downloading 500mb packages can be kind of problematic.

i think i am almost done with the plugin part. i just have to know how to replace the mesh of an entity (any idea?) and some other small details i have to ask jcl next week.

supporting other formats would be more work (but maybe this can be done later). i think x supports two uv-sets and it could be loaded automatically but in my experience most x exporters are really crappy and i think this would lead to more trouble than it is worth.



my plugin will contain 2 simple functions:

export_mesh

this exports the mesh of an entity to a text file. the file directly contains the buffer contents direct3d needs.

import_mesh

this imports such a text file, creates a new mesh from it and assigns it to an entity. (this functions isn't fully completed yet.)



the workflow will be like that:

there will be a tool which uses the plugin. it will export both model versions (model1/uv-set1, model2/uv-set2). then a python script will be started which merges the two files into one file which contains a mesh with both uv-sets.

in your game you just will have to use ent_create() with the normal model and then import_mesh() to load the mesh with both uv-sets.



i could also extend my blender exporter to export this format directly.
Posted By: fogman

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/06/07 22:25


+20 = 260 €

Go, vent, go...!
Posted By: William

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/07/07 00:08

The workflow seems intresting:

so basically,

create your level in Max,

export the models into a folder using your plugin,

export your level into WED.

Then, take your folder containing the duplicate models with different uv sets, load em into your python program, and it'll combine them.

Then in your action for every entity, have it reload the entity as the new combined mesh? Will import_mesh() read the file name of the model and do this last part automatically, or will we have to type in the mesh name for every instance of this function? Hopefully it's not the latter, cause then you'd have to create different actions or skills for every entity.
Posted By: broozar

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/07/07 00:38

why not wait for the static mesh thing in a7? it's supposed to work with shadows...
Posted By: xXxGuitar511

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/07/07 01:43

Alot of us are planning to stick with A6, at least until we see a reason to upgrade.
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/07/07 02:59

Quote:

Then in your action for every entity, have it reload the entity as the new combined mesh? Will import_mesh() read the file name of the model and do this last part automatically, or will we have to type in the mesh name for every instance of this function? Hopefully it's not the latter, cause then you'd have to create different actions or skills for every entity.


you will be able to do that yourself. just wrap import_mesh() into your own function which adds some string functions to figure out the name automatically.

Quote:

why not wait for the static mesh thing in a7? it's supposed to work with shadows...


yes, but we don't know when a7 will be out and if it will support import of light maps from 3dsmax,... in the first release.

if my plugin works out it will work with a6. another difference is that my plugin will work with models which probably still can make sense in a7 if you want to use lod for "level geometry".
Posted By: JetpackMonkey

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/07/07 07:47

Plus my 20 EUR too, 280 EUR if it isn't already in there Vent do you think it would be possible to integrate this into the obj_splitter tool you wrote? Then people could create entire levels in any 3D app that does obj, with lightmaps -- dreamy!
Posted By: maybenew

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/07/07 10:56

The workflow sounds very good!
Hope it works out well!
Posted By: Germanunkol

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/09/07 20:30

-95 = 195...
free money for everyone^^



Micha

P.S.sry! I couldn't resist! it's still at 280 euros...
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/11/07 19:23

bad news... with current engine versions it's not possible to replace the mesh of an entity. jcl said he would have to implement an ent_setmesh() function first. because of some statements in the future forum thread from last august i thought replacing the mesh would already work.
Posted By: xXxGuitar511

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/11/07 19:30

damn. That sucks...

I hope all your work has not been wasted though?
Posted By: JetpackMonkey

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/11/07 21:52

rats! thanks for trying, ventilator
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/12/07 12:30

the next beta will contain the needed function.
Posted By: maybenew

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/13/07 13:19

thank you ventilator for trying!
Posted By: xXxGuitar511

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/13/07 18:03

When will the next beta arrive anyways? I've been anxiously waiting for its release!
Posted By: Pedro_Amorim

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/14/07 02:07

Yes. This indeed looks awesome!
Im working on some outdoor level fr my paintball game and i prefer to make the level with 3dmax and do all the lighning inside of it, so baking the lightning on the textures would be better to me than using lights in wed.

i hope this come to be developed.
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/18/07 12:41

i am almost there...

there just are two problems.

it only works in lite-c so far. the plugin version still crashes and i don't know why.

and in lite-c there seems to be some problem with materials so i can't display the light map. but i am 99% sure that the mesh loads correctly and both uv-maps are there.

<edit>

it works! i still have the two problems but i combined lite-c + c-script to get the material working in the meantime.





(it's my ugly test level.)

</edit>
Posted By: zazang

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/18/07 15:03

Looks great !!!
I already feel like playing this level
Posted By: JetpackMonkey

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/18/07 15:24

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

YAY VENT!

Did u make and light that in Blender?
Posted By: fogman

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/18/07 15:25

Einfach geil!
In english: You should know what "geil" means.
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/18/07 15:38

i modeled this in blender a while ago for testing something else. modo isn't that great for things like extruding roads along a curve since it doesn't have something like a construction history or modifier stack yet. you wouldn't be able to go back to edit the curve if some change were needed.

to bake the light map i used modo. blender is supposed to also feature baking now but i haven't figured out yet how to use it properly.

Quote:

Vent do you think it would be possible to integrate this into the obj_splitter tool you wrote? Then people could create entire levels in any 3D app that does obj, with lightmaps -- dreamy!


unfortunately obj doesn't support two uv-sets either i think. so you would also have to export twice (a second time with the light map uvs) and i could add a small option to append something like _lm to the model filenames during the second export. then a script could generate all the needed mesh files. it would make the whole thing even "hackier".
Posted By: JetpackMonkey

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/18/07 16:30

Quote:

it would make the whole thing even "hackier".



Thanks, vent! The obj_splitter works great considering that people might call it hacky This approach is a little hackier but if it works, woohoo!

(EDIT: I just read that FBX does multiple UV sets and multiple meshes.. I wonder--would it be easier to make the obj splitter into an fbx splitter or use some other format that pysco library can open up? That could be pretty cool!

Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/18/07 17:20

psyco is a just in time compiler for python which makes python a bit faster. i think you mean the cgkit library? cgkit doesn't support collada or fbx.

it would be great if there were a python wrapper for the fbx sdk somewhere but i didn't find one. i am no fan of c++ but maybe i will look into the c++ fbx sdk.

<edit> hm... i wonder if the ma stands for maya ascii here and if it really is maya ascii how well it works since i guess it's a pretty complicated format. seems to be new. </edit>
Posted By: JetpackMonkey

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/18/07 22:29

Quote:

i think you mean the cgkit library? hm... i wonder if the ma stands for maya ascii




Oops cgkit, not psyco CGkit does indeed do .ma!
http://cgkit.sourceforge.net/doc2/node189.html

Apparently it even does nurbs-- which probably means it can also do simple curves-- i wonder, then, if that could be used for paths..
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/19/07 07:09

Quote:

Note: The MA importer is still work in progress.


i tried it and it had problems with my simple .ma files i exported from modo but once it is more mature it wouldn't be much work to make a real maya scene converter out of the obj_splitter. probably the tool could have much more features then since .ma contains the scene hierarchy with transformation nodes and it supports multiple uv-sets and such things.
Posted By: maybenew

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/20/07 09:17

yaix! not bad, ventilator!
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/29/07 18:54

it was some problem with adll.lib. the plugin works now! i just would like to add some improvements like a binary mesh format instead of the ascii one and maybe i will reimplement the algorithm for mixing the meshes in c so that the python tool wouldn't be necessary anymore (but i am not sure yet if that would be worth it).
Posted By: William

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/30/07 11:49

Thanks for the update!

Quote:

and maybe i will reimplement the algorithm for mixing the meshes in c so that the python tool wouldn't be necessary anymore




What would this mean? Would this make combining meshes automatic somehow(which would be great)?
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/30/07 12:04

it means that the python tool won't be needed anymore.

i already have a mesh generation algorithm which works in c now. unfortunately it's brute force and quite slow (~15 seconds for a 20000 polygon mesh) but i don't think it's a big problem since the result can be saved. doing an optimized version in c would be too much work. in python there are data structures which make it easy to make a much faster version even with python being an interpreted language but using an external tool is a bit cumbersome. i think it's nicer to have everything in the plugin.



there will be 3 dll functions:

Code:
dllfunction ent_exportmesh(entity, filename);
dllfunction ent_importmesh(entity, filename);
dllfunction ent_loadseconduvset(entity1, entity2); // this part got done by the python tool previously



Code:
	// 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");



ent_remove(e1);



// example 2

// if you already have the mesh file you can load it like that
e1 = ent_create("landscape.mdl", nullvector, 0);
e1.material = mtl_lightmap;
ent_importmesh(e1, "landscape_lm.mesh");


Posted By: maybenew

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 04/30/07 15:48

wow, i am really impressed!
Posted By: William

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/01/07 05:29

Quote:



Re: [Plugin] Import von 2. UVMap / Import of 2nd U [Re: William]
#749340 - Mon Apr 30 2007 02:04 PM
Edit post Edit Reply to this post Reply Reply to this post Quote Quick Reply Quick Reply

it means that the python tool won't be needed anymore.

i already have a mesh generation algorithm which works in c now. unfortunately it's brute force and quite slow (~15 seconds for a 20000 polygon mesh) but i don't think it's a big problem since the result can be saved. doing an optimized version in c would be too much work. in python there are data structures which make it easy to make a much faster version even with python being an interpreted language but using an external tool is a bit cumbersome. i think it's nicer to have everything in the plugin.



there will be 3 dll functions:

Code:

dllfunction ent_exportmesh(entity, filename);
dllfunction ent_importmesh(entity, filename);
dllfunction ent_loadseconduvset(entity1, entity2); // this part got done by the python tool previously



Code:

// 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");





What would the work flow be for a model already placed in WED, with an action assigned to it? Would it be like this(considering all your lighting meshes have been properly merged)?

my.material = mat_light;
ent_importmesh(my, "landscape_lm.mesh");

Is ent_importmesh basically just like ent_morph? Instead, just changing the existing mesh with the 2uvset one?

P.S - I like the idea of not using python, by doing everything in the plugin, it will indeed be much faster. Ability to save the merged mesh is also very good!
Posted By: fogman

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/01/07 13:43

Quote:

wow, i am really impressed!





Nothing more to say...
I´ll make 30,- out of my 20,- Euros.
Posted By: Machinery_Frank

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/01/07 14:02

I am also excited.

Will this also work with shaders? I would like to re-create something like this:



or this:




I already tried something like that with the sphere plug-in:



The advantage of this method over sphere is: We could use a scene-management therefore it should be possible to create bigger worlds.

If I could blend a shadowmap over a scene with normal-mapping then it would be fantastic. We could even fake static lights with this method. Visuals as seen in games like Riddick, Doom3, Quake4 (and so on) could be possible.

If someone is willing to help me with scripting and shaders then we could make a little techdemo together.
Posted By: xXxGuitar511

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/01/07 15:00

I could easily adapt my normal-mapping shader to work with lightmaps.

The only problem would be "baking" the shadows for the models.


I'm planning on buying sphere soon...
Posted By: Machinery_Frank

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/01/07 15:05

Shadow-baking will be done in Lightwave. That is no problem. The problem is:

Blending 2 uv-sets over each other. The first one contains normal-mapping or parallax shader (with tileable textues) and the second one contains a lightmap (non-tileable). The lightmap can even contain colors to simulate static lights.

A simple multiplication of the lightmap should do the job. But it must take a different uv-map into consideration.

Maybe Ventilator already has a solution for that.
Posted By: Slin

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/01/07 15:16

I tried around with Steempipes parallaxmapping shader a few days ago. I´ve got it working with levelgeometrie and blending the lightmap. What I wanted to say is, that it´s very easy to blend them together as far as the texturecoordinates are passed to the shader.

Slin
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/01/07 15:17

a solution for what?

you can apply materials and shaders and use the light map (or any other texture which uses the second uv-set) in any way you want. i am not sure though how well mixing per pixel lighting with a static light map works or how it looks like since i have never tried that.

@william: yes. it's like ent_morph().

...
there still is one problem. if ent_setmesh() gets used in my plugin then the engine crashes once it gets closed. i think either i do something wrong with compiling and linking or it's a problem on jcl's side.

and maybe i will try to make ent_loadseconduvset() faster. first i wanted to use c only so that it will also work with lite-c but i think by using some c++ stuff it could be much faster.
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/01/07 18:50

here is a beta version of the plugin: mesh.zip ~3.8mb
try it at your own risk!

it will only work with the latest a6/a7 beta!

ent_loadseconduvset() is so fast now that the import/export functions probably won't be needed anymore. i didn't test the new algorithm very thoroughly but it seems to work at a first glance.

my example model isn't that great. it has a poor light map resolution and seams at some areas.

the beta only works for meshes up to 2500 faces.

known issue: the engine will crash if you close it!

some screenshots of your tests would be nice!
Posted By: JetpackMonkey

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/01/07 19:42

Vent you are my hero!

I can't open the file up in WED tho, there is only the wmb.. is the wmp missing, or can I run it another way?

Thanks!
JPM
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/01/07 20:07

to start the example you have to run main.wdl from the script editor. if you press [0] you can fly around.
Posted By: JetpackMonkey

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/01/07 22:23

awesome it is just awesome!

screenshots a'comin
Posted By: William

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/02/07 10:30

Brilliant Ventilator!

Let me work with it a bit more, then I can provide an analysis(already got my ps/vs detailmapping shader with lightmap applied). Collision seems good all around too(c_trace/c_move, ect.)! Thanks for the demo.

@Frank -

Quote:


A simple multiplication of the lightmap should do the job. But it must take a different uv-map into consideration.




Looks like this shouldn't be a problem. Heres what I had to do in my shader:

put a shadowmap sampler:


sampler shadowmap = sampler_state
{ Texture = (mtlSkin3);
MINFILTER = LINEAR; MIPFILTER = LINEAR; MAGFILTER = LINEAR; };

Then, in the structs, I put a second set of texture coordinates. I think all shaders use "texCoord0". For having a lightmap, it looks like it's texCoord1.

struct VS_INPUT0
{
float4 pos: POSITION;
float2 texCoord0: TEXCOORD0; //1st uvmap coordinate set
float2 texCoord1: TEXCOORD1; //2nd uvmap coordinate set
float4 normal: NORMAL;
};

struct VS_OUTPUT0
{
float4 pos: POSITION;
float2 texCoord0: TEXCOORD0; //Used for colormap
float2 texCoord1: TEXCOORD1; //Used for detail1
float2 texCoord2: TEXCOORD2; //Used for detail2
float2 texCoord3: TEXCOORD3; //Used for shadowmap
float4 diffuse: COLOR;
float fog: FOG;
};

struct VS_OUTPUT2
{
float4 pos: POSITION;
float4 diffuse: COLOR;
};

struct PS_INPUT0
{
float2 texCoord0: TEXCOORD0; //Used for colormap
float2 texCoord1: TEXCOORD1; //Used for detail1
float2 texCoord2: TEXCOORD2; //Used for detail2
float2 texCoord3: TEXCOORD3; //Used for shadowmap
float4 diffuse: COLOR;
};

Put this in your vs_output():

Out.texCoord3 = In.texCoord1;

And simply in the ps_main:

float4 color = tex2D(colorMap,In.texCoord0);
float3 texture0 = tex2D(detail0, In.texCoord1);
float3 texture1 = tex2D(detail1, In.texCoord2);
float4 shadow = tex2D(shadowmap, In.texCoord3);

return (color*vecAmbient+(color * In.diffuse))*shadow;

I don't know if your supposed to multiply by the shadow, as I'm no shader programmer(and admit, took a few minutes to even figure this out). But it works, and also colored lighting on the light maps work too!
Posted By: fogman

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/02/07 10:36

I hope I´ll have some time today to play around with it. I´ll give you feedback than.
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/02/07 18:32

the engine shutdown crash probably happens because the plugin and the engine didn't get compiled with the same directx sdk. i will find out which sdk the engine uses and try it with that one then.

i am looking forward to see some screenshots!
Posted By: JetpackMonkey

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/02/07 20:55

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



Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/02/07 23:52

if a model pair causes a crash i would need it for investigation.

does anyone else have crashes? (except the one when closing the engine!)

(both models need the same amount of faces, the vertex positions have to be exactly the same and the corresponding faces must have the same vertex order. maybe i forgot some check to avoid a crash if one of these isn't the case.)

...
btw. you can comment out all export and import functions since they probably aren't needed anymore.
Posted By: William

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/03/07 04:50

No crashes here, as I still haven't tried my own models.

Currently having trouble getting my 2 models out of max. For example, I've got 2 mapping channels, the first one with the normal UV, the second with another UV. But max2mdl seems to only export models with map channel #1. Perhaps I'm doing something wrong, as I'm very new when it comes to baking levels. If someones got a solution for it, please post(I think earlier it looked like Mabyenew had no problem exporting with this?).


Edit:

Got the mesh exports working! Turns out to export as a different map channel, you have to UVW Mapping modifier, and select your map channel there. This is very simple and quick.

Anyways, i'm getting the same error as Jetpackmonkey when I try to combine my 2 meshes thru script. Basically a problem with the "loadseconduvset", then after that error, there is one with the "ent_importmesh". After running, the model has it's normal tiling textures, but with a bunch of it's faces shaded black here and there.

Code:
  str_for_entfile(tempstring,my);
//str_cpy(aemo2, tempstring);



if(str_cmp(tempstring,"YY_MAINCLIFF.MDL") == 1)
{

// // example 1
//
// // load model with texture uv-set

// // load model with light map uv-set
e2 = ent_create("l_maincliff.mdl", nullvector, 0);
//
// // generate and assign a new mesh with both uv-sets
ent_loadseconduvset(my, e2);
ent_remove(e2);
//
// // save mesh with both uv-sets for faster reuse
/// ent_exportmesh(e1, "landscape_lm.mesh");
//
//
//
//ent_remove(my);

// ent_importmesh(my, "l_maincliff.mesh");
}


Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/03/07 12:23

how does the error message exactly look like?

are you sure you don't mix up my beta popups with crashes? i stupidly used the error() function for popups but if it is no error it says "(this is no error message!)" at the bottom.

there probably is something wrong though if you get black triangles and i would have to investigate that with your models.
Posted By: Wicht

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/03/07 15:06

My first screen with ventilator's mesh-plugin


Lightwave



A6-Engine

Posted By: fogman

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/03/07 15:51

A dream comes true...
Looks like a night-shift for me.
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/03/07 16:25

hm... i did some tests with messing up the second model (moved some vertices around so that the correct triangles won't be found on the second model) and the algorithm seems to be quite forgiving. i didn't get any crashes. just the light map was wrong then on those triangles.

jetpack_monkey's test model worked for me and william's model seemed to work too but he forgot to send me the light map so i couldn't check if it displays correctly. he had overlapping areas in the light map uvs though which probably won't give good results.

jetpack_monkey's test model:

Posted By: xXxGuitar511

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/04/07 00:47

This only works with 6.6* [private-beta] right?

I can't wait to work with it, although I probably won't be able to since I don't have any way for generating the lightmaps...
Posted By: lostclimate

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/04/07 01:07

just get blender, it can make them for you.
Posted By: William

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/04/07 01:11

Yeah, my model works great. I was just at the end of a long day(sleepy...) when testing this and thought that I was doing something wrong.

Anyways, I want to make good on my offer of 150euros, so maybe share your Paypal so I(and the rest) can pay you, and get a dll without all the messages.
Posted By: xXxGuitar511

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/04/07 03:13

I've got blender, but I'm too busy+lazy to figure out how to use the damn thing...

One of these days I'll spend some time with it...
Posted By: lostclimate

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/04/07 03:47

just go to the blender noob2pro tutorial and look for how to unwrap an object, then all you have to do is render a lightmap
Posted By: xXxGuitar511

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/04/07 04:33

Thanks, I'll check it out tomorrow. (It's 0:32, and I have work tomorrow )
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/04/07 15:06

here is a new beta version: mesh.zip ~2.8mb

now the plugin is compiled with the same directx sdk as the engine so the engine shouldn't crash anymore on shutdown.

@xxxguitar511: yes, it only works with the private beta at the moment since the plugin needs ent_setmesh(). it will work with the final a6 release and with a7.
Posted By: JetpackMonkey

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/05/07 13:57

I can't seem to fly around with this latest version, any thoughts?
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/08/07 18:16

maybe you pressed the wrong [0] key? you could also call _tog_mov(); in the main function.

any other feedback? does everything work?
Posted By: JetpackMonkey

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/08/07 18:45

Oh!! Sorry vent, I thought I got back to you via e-mail -- yeah! I can fly around with it now, works great

$$$ btw everyone who said they'd pitch in, don't back out of your promise now that vent has delivered the goods $$$


(my paypal thank you coming soon)
Posted By: fogman

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/08/07 18:47

Quote:

the engine shouldn't crash anymore on shutdown




It crashes on my machine (on shutdown).
Maybe it´s a WinVista problem.

Besides that your example works fine and it looks very satisfying.
I´ll have to do some small tests, because I don´t have the time to make something bigger atm.

Edit: For the money - Vent could give us advice via PM on how we can pay.
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/08/07 19:06

Quote:

Oh!! Sorry vent, I thought I got back to you via e-mail -- yeah! I can fly around with it now, works great


i got your mail but i thought it looks stupid if i ignore your post here.

Quote:

$$$ btw everyone who said they'd pitch in should pony up now that vent has delivered the goods $$$


i think it still would make sense to stay in beta for a while. there isn't even a final 3dgs version that can run it.

after some more beta testing the sponsors of this thread could do their payment and then i will release the unlimited plugin for everyone. i hope this works out. otherwise i will have to think of something else...

every sponsor could get mentioned in the readme (with link and banner if wanted) and the ones whose payment was above average maybe could also get the source. what do you think?

Quote:

It crashes on my machine (on shutdown).
Maybe it´s a WinVista problem.


are you sure you used the version of the second download? hm... anyone else with that problem on vista? does it still happen for anyone on xp?
Posted By: JetpackMonkey

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/08/07 19:56

Me, I'm using the second version with Vista and have no problems, and no crash on closing acknex afterwards. The 2222 face model prevents me from re-building your demo mesh, though, but my own ones are under the limit and work well.
Posted By: fogman

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/08/07 20:07

I apologize, I´ve used the old version.
It works without crash.
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/08/07 20:17

buh... i am glad it works. it could have been really nasty if this had been some strange vista problem.
Posted By: William

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/09/07 07:16

Quote:


after some more beta testing the sponsors of this thread could do their payment and then i will release the unlimited plugin. i hope this works out. otherwise i will have to think of something else...




This should be fine. Just send me an PM with your Paypal. I'd be willing to pay right now, as currently, I'm limited by the poly limit and the error messages are quite annoying.
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/09/07 18:58

here is a code snippet which cycles through all entities of a level and applies a light map if the "_lm" files exist for the entity. i haven't tested it yet. it's just an idea...

Code:
// example 3
function file_exists(filename)
{
var filehandle;
filehandle = file_open_read(filename);
if(filehandle)
{
file_close(filehandle);
return(1);
}
else
{
return(0);
}
}

string tempstring1;
string tempstring2;
material* tempmaterial;
entity* tempentity;

function 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.skill100 = mtl_create(); // i guess they should be deleted again when changing the level
tempmaterial = you.skill100;
tempmaterial.effect = mtl_lightmap.effect;
tempmaterial.skin1 = bmap_create(tempstring2); // i guess they should be deleted again when changing the level
you.material = tempmaterial;

tempentity = ent_create(tempstring1, nullvector, 0);
ent_loadseconduvset(you, tempentity);
ent_remove(tempentity);
}

you = ent_next(you);
}
}



i thought some more about payment. it's kind of unfair if not everyone pays the same amount. i will just sell the plugin individually for 20€.

...
i also found out that vec_for_mesh()/vec_to_mesh() won't work anymore with a replaced mesh (but ent_vertices(), vec_for_vertex(),... still work). there is nothing i can do about it but i think it's no big issue since for a light mapped mesh modifications wouldn't make much sense anyway since the lighting got done for the unmodified mesh and wouldn't be correct anymore. if you absolutely need to modify the mesh you could do the modifications to both models before you use ent_loadseconduvset().
Posted By: Pappenheimer

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/09/07 21:14

I enjoy every picture of the results of this tool!
I still don't wanna use the last beta, but I am amazed by your tool!
Great job!

A question came to my mind: what about the framerates?
Did anyone compare it to similar maps (although it is anyhow not comparable), maybe to a multitextured terrain?

Are the shown levels made of a single model?
What about different models with different lightmaps in the same level?
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/09/07 21:19

the frame rates are good. light mapping is cheap.

the example level is one model with about 20000 faces and it runs with about 400fps on my gf6600.

i think for performance it would be better to split the level into chunks with less than 5000 faces. it's no problem to use different models with different light maps.
Posted By: Pappenheimer

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/09/07 21:27

Wonderful!

Does anybody have other landscapes or different moods
and lighting of the same landscape to show?
Just for fun! It looks so nice!
Posted By: JetpackMonkey

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/10/07 10:13

Isn't it awesome? Behold!! We must build a shrine to it!

Those frame rates are fantastic, and the automatic lm loading code is definitely a step towards making level creation without hardcoding it (!!!)
Posted By: William

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/10/07 11:10

Heres another little snippet for applying lightmaps:

Code:
 

str_for_entfile(tempstring,my);

str_lwr(tempstring);
str_cpy(lightstring,"z");
str_cat(lightstring,tempstring);

//load model with light map uv-set
e2 = ent_create(lightstring, nullvector, 0);

//generate and assign a new mesh with both uv-sets
ent_loadseconduvset(my, e2);
ent_remove(e2);




Basically you can just save your models that contains lightmaps with a "z" in front of there original names. If you put this in your action, every entity with this action will load a lightmap. If you want to have only some entities with this action load them, then you can just specify that with a flag or skill.

I wish there was a way to morph the skin2 of an entity. It would make automatic lightmap texture assigning to your non-lightmap models skin2 possible.
Posted By: maybenew

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/16/07 14:53

I get a beta expired message.

Can you tell me about the stability of the plugin? What can cause crashes, are there things to pay special attention to?

Other than that I am ready to license the plugin
Posted By: Machinery_Frank

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/16/07 15:02

I created a fixed function effect that combines color texture, normal-map via dot3-bumpmapping and the lightmap coming from second uv-set. I am planning to create similar effects for metal, glass and reflection via cube-maps.

So I am also very interested in licensing to check that out.
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/16/07 15:04

mesh_plugin_demo.zip ~ 2.8mb

i have uploaded a time unlimited demo with a 777 polygon limit.

i don't think it will crash anymore.

things to know:
- the two models must have the same face count
- the vertices of the two models must be at exactly the same positions
- the triangles of the two models must have the same vertex order
(these three points usually are the case if you export them from the same application)
- you can't use vec_for_mesh/vec_to_mesh anymore with a replaced mesh
- it only works with the beta at the moment

if you want to license it already you can write me a pm.

(something else to know:
there seems to be a model loading bug in the recent betas.
http://www.coniserver.net/ubbthreads/showflat.php/Cat/0/Number/751735/an/0/page/0#Post751735
my plugin is only interested in the texture coordinates of the second model but because of this bug the second model needs some dummy texture. best assign the light map as external texture like in my example. this isn't a problem of my plugin though.)
Posted By: lostclimate

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/16/07 20:08

so does this work without the beta yet?
Posted By: Machinery_Frank

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/16/07 20:51

So we just have to hope that an A6.6 will appear very soon.
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/21/07 18:54

by the way... 6.6 is out now!
Posted By: Samb

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/22/07 15:03

testing it at the moment.
but my model is very.. VERY dark...
I don't know why.. any clue?
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/22/07 15:13

the brightness depends on the used material and on your light map.

i think with my example material every light map value above 128 brightens the texture and every value below 128 darkens the texture.

<edit> i checked your models and the reason was that they didn't have the same scale. the vertices must have exactly the same positions otherwise the triangles won't be found on the second model. if a triangle doesn't get found its texture coordinates of the second uv-set get set to 0. </edit>
Posted By: Samb

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/22/07 16:22

ok, got it to work
here my test:
without 2nd uv map


with 2nd uv map:


nice
Posted By: xXxGuitar511

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/30/07 03:44

Can you recommend any [free] programs for generating lightmaps? I'm very interested in this, but I don't have any way of generating lightmaps (and I'm cheap - lol )
Posted By: lostclimate

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/30/07 06:16

im telling you if you can just figure out how to import to blender, its simply a matter of clicking on button and you have it.
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/30/07 21:00

http://www.ambiera.com/irredit/
this could work too. has anyone tried it?
Posted By: lostclimate

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/30/07 22:19

it doesnt export lightmaps, it is only used for irrlicht, people keep bringing up irredit, and irredit is not meant for any other engine than irrlicht.
Posted By: ventilator

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 05/31/07 10:06

no, i had a look... it can export collada format and the light map but getting this collada file into 3dgs could be a bit tricky.
Posted By: Pedro_Amorim

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 08/24/07 12:10

Hi,
I'm having a little trouble using this plugin.
I have my mdl7 with the texture and the mdl7 with the second uvmap with the lightning map apliied. Im ready to go. I just dont know where to start. I donwloaded the plugin. Where do i place it? and how do i use it?

Sorry for the n00bish questions. lol
Posted By: JetpackMonkey

Re: [Plugin] Import von 2. UVMap / Import of 2nd U - 08/24/07 16:40

Put it in the acknex_plugins folder in your gamestudio folder. Then check out the demo files that came with it, I think that should have enough info for you.. or if they aren't in there, I'm pretty sure there is a link in this thread to it. It works very well!
© 2024 lite-C Forums