Blender to MAP exporter

Post anything to do with editing Nexuiz here. Whether its problems you've had, questions, or if you just want to show off your work.

Moderators: Nexuiz Moderators, Moderators

Postby z80 » Wed Jul 29, 2009 4:32 am

Guys, hello again!

I've done a few little improvements to the exporter. Now it has an appropriate GUI with an explanation of what it can do.

But bad new is that now it consists of two files :) So now one file depends on another.

nexuiz.py link is: http://blend2map.pastebin.com/f73f72004
nexify.py link is: http://blend2map.pastebin.com/fbea5f0a

To install one should but "nexuiz.py" to "blender/.blender/scripts" folder and "nexify.py" to "blender/.blender/scripts/bpymodules".

It's version "0.03".
Fixes list is the following:

- textures can be overwritten with shader names using Blender object logic properties named "texture[i]" (i = material index - 1) with string value coinciding with shader name.

- it has switchable console output.

- good GUI concerning to previous one.

And also I still think how to make patches export. The problem is NetRadiant understands only patches of 3, 5, 7, 9, 11, 13 resolution. Guys, how should I do? Is it enough to put it on a user to watch correct patch resolution or it's required to resize patches? Any ideas?

toneddu2000: Concerning translating code to C++. Well ........ well ..... actually it's possible but in this case user of this code is to compile and install it. And it would take me months to do that :) :) :) So IMHO until exporter doesn't work good enough it would be better to concentrate on improving it's logic.

For the beginning let's make exporter logic as good as we can and only after that ........ :wink:
Last edited by z80 on Wed Jul 29, 2009 4:48 am, edited 1 time in total.
z80
Advanced member
 
Posts: 92
Joined: Sun Jul 26, 2009 7:35 pm
Location: Russia

Postby divVerent » Wed Jul 29, 2009 4:47 am

In NetRadiant svn, patches are up to 31x31. q3map2 always allowed this size.
1. Open Notepad
2. Paste: ÿþMSMSMS
3. Save
4. Open the file in Notepad again

You can vary the number of "MS", so you can clearly see it's MS which is causing it.
divVerent
Site admin and keyboard killer
 
Posts: 3809
Joined: Thu Mar 02, 2006 4:46 pm
Location: BRLOGENSHFEGLE

Postby toneddu2000 » Wed Jul 29, 2009 9:16 am

It doesn't work :cry: !
I tried to put first the first file (the one with the nexuiz path) in scripts and the second (the one with all the callback strings) in bpymodules and then I switched them but in first case Blender Scripts window doesn't show the script and in the second case terminal returns me this error
Code: Select all
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/toneddu/progs/grafica/blender/.blender/scripts/nexify.py", line 25, in <module>
    from nexify import CNexify
  File "/home/toneddu/progs/grafica/blender/.blender/scripts/nexify.py", line 25, in <module>
    from nexify import CNexify
ImportError: cannot import name CNexify
Saved session recovery to /tmp/quit.blend


and creates a nexify.pyc file (i renamed nexify.py the one with callbacks)

maybe I made a mistake renaming files, but I'll try this evening, however huge thing including shaders, Thx! :D
for the c++ method, I know, it would be a huge work and, for that purpose, there still be Netradiant :wink: !
toneddu2000
Alien trapper
 
Posts: 251
Joined: Mon Mar 09, 2009 7:56 pm
Location: Italy

Postby z80 » Wed Jul 29, 2009 10:44 am

toneddu2000 from the code you've supplied I can see that you named files wrong :)

To fix please change their names ( nexuiz -> nexify and nexify -> nexuiz ) and put "nexify.py" to "scripts/bpymodules" and "nexuiz.py" to "scripts". :)

NEXIFY.PY is module and NEXUIZ.PY is exporter script!!!
z80
Advanced member
 
Posts: 92
Joined: Sun Jul 26, 2009 7:35 pm
Location: Russia

Postby z80 » Wed Jul 29, 2009 6:46 pm

Version 0.04 of the exporter.

Items added: NURBS surfaces export as patchDef2 MAP file objects.

nexify.py: http://blend2map.pastebin.com/f3ac540cd
nexuiz.py: http://blend2map.pastebin.com/f86e531f

Again first one "nexify.py" to "SCRIPTS/PBYMODULES",

and "nexuiz.py" to "SCRIPTS".
z80
Advanced member
 
Posts: 92
Joined: Sun Jul 26, 2009 7:35 pm
Location: Russia

Postby toneddu2000 » Wed Jul 29, 2009 10:45 pm

So, unfortunately it doesn't work! I used now correct names now and once loaded the script appear in its new body (very cool the prepare button and the brief, considering that you made it in only two days :D ), but when I leave objects with UV (with orco coordinates) it returns me this error:

Code: Select all
________________________________________
inspecting object:
        type = Mesh
        name = Cube.005
        object properties:
        convex = 1
        shape = convex

____________________________________________
inspecting object:
        type = Mesh
        name = Cube.004
        object properties:
        convex = 1
        shape = convex

____________________________________________
inspecting object:
        type = Mesh
        name = Cube.003
        object properties:
        convex = 1
        shape = convex

____________________________________________
inspecting object:
        type = Mesh
        name = Cube.002
        object properties:
        convex = 1
        shape = convex

____________________________________________
inspecting object:
        type = Mesh
        name = Cube.001
        object properties:
        convex = 1
        shape = convex

____________________________________________
inspecting object:
        type = Mesh
        name = Cube
        object properties:
        convex = 1
        shape = convex
Exporting:
Traceback (most recent call last):
  File "/home/toneddu/progs/grafica/blender/.blender/scripts/nexuiz.py", line 277, in b_event
    gui_export_Callback()
  File "/home/toneddu/progs/grafica/blender/.blender/scripts/nexuiz.py", line 355, in gui_export_Callback
    nexify.writeFile()
  File "/home/toneddu/progs/grafica/blender/.blender/scripts/bpymodules/nexify.py", line 427, in writeFile
    self.writeMesh( file, obj )
  File "/home/toneddu/progs/grafica/blender/.blender/scripts/bpymodules/nexify.py", line 508, in writeMesh
    texture, x, y, ang, w, h = self.calcFaceUv( face, materialsList, textureOverDict )
  File "/home/toneddu/progs/grafica/blender/.blender/scripts/bpymodules/nexify.py", line 731, in calcFaceUv
    tex_path = g_nexuiz_path.replace( '\\', '/' )
NameError: global name 'g_nexuiz_path' is not defined


if I unwrap all the meshes it gives to me this error:

Code: Select all
Traceback (most recent call last):
  File "/home/toneddu/progs/grafica/blender/.blender/scripts/nexuiz.py", line 277, in b_event
    gui_export_Callback()
  File "/home/toneddu/progs/grafica/blender/.blender/scripts/nexuiz.py", line 355, in gui_export_Callback
    nexify.writeFile()
  File "/home/toneddu/progs/grafica/blender/.blender/scripts/bpymodules/nexify.py", line 427, in writeFile
    self.writeMesh( file, obj )
  File "/home/toneddu/progs/grafica/blender/.blender/scripts/bpymodules/nexify.py", line 508, in writeMesh
    texture, x, y, ang, w, h = self.calcFaceUv( face, materialsList, textureOverDict )
  File "/home/toneddu/progs/grafica/blender/.blender/scripts/bpymodules/nexify.py", line 574, in calcFaceUv
    matr = obj.matrixWorld
NameError: global name 'obj' is not defined


I tried everything, I changed path to nexuiz, cause I've svn version and my path was /home/user/games/Nexuiz/trunk to /home/user/games/Nexuiz and I copied everything there, but nothing :cry: ! I really don't have idea, my objects are all center cursor,are resized to 1,1,1 and have a name!I use ubuntu 9.04.Could be a system bug?Maybe are you using Vista or Xp?
toneddu2000
Alien trapper
 
Posts: 251
Joined: Mon Mar 09, 2009 7:56 pm
Location: Italy

Postby z80 » Thu Jul 30, 2009 5:01 am

I see, it appears, I've repaired one thing but broken another :) Good work, thanks! Console output immediately tells me what's wrong.

Obvious mistakes, I'm very sorry. It will take me an hour to fix it.
z80
Advanced member
 
Posts: 92
Joined: Sun Jul 26, 2009 7:35 pm
Location: Russia

Postby z80 » Thu Jul 30, 2009 6:55 am

Here it is.

nexify.py: http://blend2map.pastebin.com/f24c85d48
nexuiz.py: http://blend2map.pastebin.com/f569f80a2

Version 0.05. Fixed problems:

- with exporting textured objects.

- for surface to be textured "texture" property must exist.


By the way, toneddu2000, IMHO it is worth to use UV instead of ORCO for texture to match in NetRadiant.

And one more thing. As far ar in blender texture is mapped using UV but in NetRadiant using X,Y,ANG,SZ_X,SZ_Y not any UV set could be transformed into appropriate NetRadiant coordinates set. Make sure you texture your face in such a way that uv geometry transformation is a combination of shift, scale and rotation transformation of initial face shape!!! It means it should be NO TANGENT SHIFTS!!!
z80
Advanced member
 
Posts: 92
Joined: Sun Jul 26, 2009 7:35 pm
Location: Russia

Postby toneddu2000 » Thu Jul 30, 2009 10:52 am

AWESOME! :D It works flawless! It shows shaders(color,bump,normal and gloss),uv texture and all the meshes!
Thanks a lot!
Ok, I think it's benchmark time :wink: ! If I have to be honest I didn't understand the NO TANGENT SHIFTS argoments for textures. Could you please explain it and the light parameters (how can I set a sun in blender, where I found Blender object logic) argument. Because, if you want, I'll make a pdf manual with a short export tutorial which I'll be able to upgrade every time you upgrade the script! If you want, of course!
toneddu2000
Alien trapper
 
Posts: 251
Joined: Mon Mar 09, 2009 7:56 pm
Location: Italy

Postby z80 » Thu Jul 30, 2009 1:07 pm

toneddu2000: in other words it would be better to

1) unwrap each face UV set along this face normal
and
2) move, scale and rotate all UV vertices but NOT drag them one by one.

If there two conditions are met there shouldn't be problems.

Blender logic section appeares in Buttons window if one presses F4 (or click the first button with magenta smile face on it). In Logic window press ADD PROPERTY choose type BOOL/INT/FLOAT/STRING according to a property type wanted, name it sun/target/....

Sure it would be nice if you make some document.

At this moment objects of "Mesh", "Surf" and "Lamp" are supported by exporter.

All 3 object types can have BOOL property "ignore", if it's true, object is ignored when exporting. This property is assigned to convex meshes during PREPARE procedure when prisms are added for each face of that concave mesh.

"Mesh" could have the following properties:

- "height" (float) - if mesh is concave this value overwrites the "extrude height parameter".

- "texture[i]" (string), i = 0, 1, 2, ... - overwrites texture name of faces material with index (i+1). (+1 is because in GUI materials numbering starts form 1, but in script form 0)

- "convex" (bool) - just informational property. It's set automaticaly when PREPARE button is pressed. It tells to a user if this is an appropriate mesh geometry or not.


"Lamp" may have properties:

- "sun" (bool) - is it a sunlight without attenuation or not.
- "has_target" (bool) - is it a directional light.
- "target_x", "target_y", "target_z" (float) - where is target point for directional light.
- "radius" (float) - directional light spot radius.


"Surf" now can have only one property

- "texture" (string) - it's material name.
z80
Advanced member
 
Posts: 92
Joined: Sun Jul 26, 2009 7:35 pm
Location: Russia

PreviousNext

Return to Nexuiz - Editing

Who is online

Users browsing this forum: No registered users and 1 guest