STEAM GROUP
Blender Source Tools BleST
STEAM GROUP
Blender Source Tools BleST
197
IN-GAME
1,471
ONLINE
Founded
November 8, 2013
All Discussions > Help > Topic Details
Zyl Sep 10, 2015 @ 6:51pm
Export custom normals to SMD
Hello,

I have a plugin which edits normals all in an attempt to save polys, but Blender Source Tools appear to still use plain smoothed normals? Here is (roughly) what the plugin does (within an operator execute function definition):

me = context.object.data
bm = bmesh.new()
bm.from_mesh(me)
for v in bm.verts:
  v.normal = some_custom_normal
bm.to_mesh(me)

The change is visible in Blender and is preserved between saving and loading the .blend file. Only entering edit mode on the mesh resets the normals. Can I have it my way?
Last edited by Zyl; Sep 10, 2015 @ 6:52pm
< >
Showing 1-8 of 8 comments
Zappy Sep 10, 2015 @ 11:11pm 
I'm not sure if I understand you right, but the Blender Source Tools (by default) don't import SMD normals. But exporting them should be fine. Either way, I know for certain it works with DMX.
Zyl Sep 11, 2015 @ 4:57am 
I don't think I can use DMX for a Source SDK 2006 game. Is someone with extensive Blender Python API knowledge around who can shine some light on this?
Zappy Sep 11, 2015 @ 5:06am 
Again, it should EXPORT fine, just not IMPORT. Also, Half-Life 2 was released in 2004, and I'd be very surprised if it does not use DMX. At least try before saying it won't work.
Zyl Sep 11, 2015 @ 7:26am 
I am trying to export. Studiomdl says it "can't open file" when I use dmx. Now this may be because I don't know which "binary" and "model" target version to specify.

Anyway, I solved the problem. The source of the problem is the triangulation process: https://blender.stackexchange.com/questions/7033/how-can-i-triangulate-a-mesh-without-changing-the-object

I solved this by adding and applying a triangluation modifier myself, then applying my normal modification, and then writing my own SMD exporter which expects triangles. The custom normals don't get touched and everything is fine. People who want to use this technique should make sure to save backups of their .blend files without the triangulation modifier applied.

Here is the plugin I wrote: http://pastebin.com/0mfyv4yn
Zappy Sep 11, 2015 @ 7:42am 
You do know about the "Engine path" path, right? If set to a directory with StudioMDL, it should auto-detect which DMX version to use. Additionally, the QC itself might say ".smd".
Zyl Sep 11, 2015 @ 9:56am 
Setting engine path forces SMD being used for me. The DMX/SMD switch GUI element is omitted.
Zappy Sep 11, 2015 @ 10:35am 
Then it only supports SMD, it seems. Oh, well. At least you made something that works for you.
Last edited by Zappy; Sep 11, 2015 @ 10:35am
Artfunkel Sep 11, 2015 @ 11:44am 
Run the "Add Custom Split Normals Data" operator then edit the mesh's loop normals. That's the proper way of doing it and those normal data will be stored permanently in the blend, never to be recalculated.

I'm pretty sure they will survive export to SMD too, but triangulation may indeed be an issue. The custom normals system just doesn't support topological changes. :(
< >
Showing 1-8 of 8 comments
Per page: 1530 50

All Discussions > Help > Topic Details
Date Posted: Sep 10, 2015 @ 6:51pm
Posts: 8