lightmap with 2 .x files

Hi there,

I’d be happy to import & light map an .x object exported from gile[s].
gile[s] exports 2 .x file, one for the texture colors, the other one for the light mapped geometry with its own uvset i guess.
I wonder how to use that in panda ?
Shoud i load both models and then try to blend 'em ?
Or get the texturestage from an object and paste it on another one ?

@IPKnightly: in this case it’s not only about multitexturing but about multiple uv-sets,too.

panda supports several uv-sets per vertex natively. if you have 2 x files, one with the uv-set for the textures and one with the uv.set for the lightmap you could load both into panda, read both uv sets and write them together in one new object which will make your map.
you can set up a little converte which does this for you and outputs a *.bam or *.egg file.
if you wanna do it read the section in the manual.
its not that easy to understand all of this, maybe a more experienced pandauser can help you out with it.

i havent tried out to use multiple uv-sets per vertex so maybe someone else might add more details here =)

Thanks guys,

ThomasEgi, thats exactly what i want, i try it right now (at least understand how it works !)

good luck =)
in case it’s too much work you might want to check out the new blender version+ latest chicken exporter for it.
it features render to texture on anything (including radiosity and global ilumination) and multiple uv-sets.
uhm another idea would be to convert both files to egg files and write a small python app which goes through the lines appending the 2nd uv-coords there. might avoid a lot of overhead with pandas runtime handling of the data.

for a small testroom you might be even able to add the data in a spreadsheet app. like exel or the one from openoffice =)

I’ll wait a bit for the next release (i’m too lazy to use betas :wink:) of blender before try its brand new multiuv features. But yep i’m almost sure we’ll have something cool maybe with .egg exporter updates.
Panda3d seems awesome !
BTW do you know maybe some examples of code close to what i wanna do ?

hmmm unfortunately i dont. but if you go the way over the egg files you can use python’s standart modules to read files.
since both of your modelfiles are almost identical it shouldn’t be too hard to copy the data from one file to the other.
since egg’s are human-readable textfiles you can make good usage of pythons file readers like in this examlpe
i might a a few lines of code lying around which i used to read and write lists to and from HDD. tell me if you need further help with it =), i cant promise anything but i’ll try.

oh and look at the egg-documentation… it’s somewhere. aah… in the panda docu :stuck_out_tongue: if you look at a egg file and have this docu nearby you’ll most likely see what you have to do.

Hi there,

After a lot of reading, i just think its too complicated for a beginner like me.

Maybe i should just wait that some python guru codes a blender plugin or something which exports multi-uvs. Right now its seems quite annoying for me to have to code so strongly to just get a lightmap displayed.

At least if i could just copy uv set from one Node to another one, with a few commands it could be nice, but if i understandd well, i have to :

  • load my models, dynamically create a Newnode object, transfert a lot of informations from loaded objects to my dynamic object with loops picking values in arrays (and i have to deal with array formats), and reinjecting those values in my new object…
    Maybe i’ve missed simple and powerfull commands to do that, like a global copy from one Node to another, but i’m not sure.
    Some workarounds seem possible with Maya, but i gotta learn how to use it, and i dont know if its possible with the free version.

Maybe i should learn other stuffs before playing with all thoses concepts, but come on, i read Panda3d is easy, and i cant even simply display lightmapped models ?

(please forgive my poor english skill )

you dont have to wait^^ just get the latest blender build and the latest chicken exporter for it =) and it should work. psiberpunk might be able to help you out when it comes to exporting multiple uv sets, he wrote the whole chicken thing (including support for multiple uv sets).
and like i said.the other idea would be to have a look at some egg files.
the vertex data in it looks like this :

<Vertex> 1 {
        0.278522 -0.210334 9.598626
        <UV> { 0.716456 0.570883 }
        <Normal> { 0.555485 -0.141214 -0.819448 }

all you need to do is to copy the line from one file to into the other file at the right position… or at least that’s my idea how to get it work. avoids all the panda caused vertexdataarrayoverhead and such. =)
it’s much simpler to work with text files than with those vertexarraythigns (at least from my point of view)

To avoid repetition, read this post to get the latest Chicken unstable version and instructions on how to use multiple UVs and its limitations.

Hi guys & thanks :slight_smile:

ThomasEgi :
Yep i had a look @ egg files, seems pretty clear, but it still seems a lot of work for me at this moment.

psiberpunk :
Okay, i see that there is some hope there :slight_smile: I will keep an eye on that thread !
Question do you know a way to import my dual .x files into blender and then merging their uvsets into one object with multilayer uvs ?

Well, I know there’s an .x importer script for Blender but I’m unsure how good it is. If it worked ok, I’m afraid the only way to do a merge of the two objects into one with the UVs from both would be to write a script to perform that operation.
It shouldn’t be too difficult if you’ve written Blender scripts before. It can probably be done in 30 lines or so. Maybe I’ll give it a crack and post it here.

Heh, guess 30 lines was an overstatement, here’s a script that does what you need:

from Blender import Object
s = Object.GetSelected()
one, two = s[0].getData(mesh=1), s[1].getData(mesh=1)
one.activeUVLayer = 'UVTex2'
for i, f in enumerate(one.faces):
	f2 = two.faces[i]
	f.uv = f2.uv

Just select two objects, and it’ll copy the first selected object’s active UV layer into a new UV layer on the second called ‘UVTex2’. You might have to de-select and re-select the target object to see the change.

Thanks a lot psiberpunk ! really, i’ll try it tomorrow !