KatsBits Community

Game Editing => 3D Modeling & Content Creation => Topic started by: ellisgl on May 02, 2012, 03:46:16 PM

Title: Block Primitives instead of Planes
Post by: ellisgl on May 02, 2012, 03:46:16 PM
So I've created some simple items in SketchUp, exported the file as a COLLADA file, imported them into blender, converted faces to quad then export as a Qauke Map. The problem I'm having is that it's not exporting as "block primitives" and exporting as planes. Having 6 polys for a single block is annoying to work with. How do I get around this issue?
Title: Re: Block Primitives instead of Planes
Post by: kat on May 02, 2012, 04:43:00 PM
That sounds like you've not 'Rem Doubled' the mesh before export. You need to make sure you do this otherwise yes, it'll export a series of panels rather than blocks. In Edit mode, select a face and move it, if it moves independent of other faces around it then you know it's detached and you need to Select All and "Remove Doubles". Have a read through of this if you've not already done so - making a simple map in Blender (http://www.katsbits.com/tutorials/blender/map-basics-tutorial.php). Also, make sure your 'blocks' are all closed (solid and without any wholes) meshes otherwise those too will export as panels.
Title: Re: Block Primitives instead of Planes
Post by: ellisgl on May 02, 2012, 05:46:16 PM
The remove doubles work on my cube, but I have a hexagonal column that isn't wanting to play well. I can't find any "holes" in the columns. http://houseofellis.net/misc/netfire.blend (http://houseofellis.net/misc/netfire.blend)
Title: Re: Block Primitives instead of Planes
Post by: kat on May 02, 2012, 08:22:15 PM
OK.. yeah, you can't really make objects like that and have them export correctly out from Blender. First your hex shapes are relatively small, second they're off-grid and third they're rotated at slight angles. All that adds up to the problems you're having because the *.map format doesn't have the accuracy you need to represent those types of objects as brush volumes.

So... when you make that in SketchUp or you import it into Blender you're going to need to make quite a few adjustments to make sure it conforms to what the format needs - make sure the hex is on-grid and rotated properly to suit (this means the major sides must align to the grid).

If none of that works, export the mesh as a model. By the way, it's suggested you use the reference blocks (http://www.katsbits.com/tools/#misc), your table is a little small and using the scale value could be a bit tricky to use due to the objects non-scaled size.

Table in Blender
(https://www.katsbits.com/misc/blender/netfire_fixed_blender.jpg)

Resulting brushwork in GtkRadiant
(https://www.katsbits.com/misc/blender/netfire_fixed_gtk.jpg)
Title: Re: Block Primitives instead of Planes
Post by: ellisgl on May 02, 2012, 09:33:40 PM
Thanks for the info. I found this link that might help others out too. http://www.maximumpc.com/article/howtos/howto_make_left_4_dead_map_google_sketchup?page=0,4
Title: Re: Block Primitives instead of Planes
Post by: kat on May 02, 2012, 10:22:05 PM
Not too sure about Hammer but ideally you want to avoid using use snap increments that small, again because of brush accuracy issues, generally speaking you want your objects to be blocks that are as large as possible to reduce the amount of map data that gets generated in BSP - using a lot of small objects eats into BSP like crazy so items like your table should really be models rather than brushwork. So if you were modeling a building use a larger snap value than if you were meshing up furniture, that ensures you're building optimally from the get-go.
Title: Re: Block Primitives instead of Planes
Post by: ellisgl on May 03, 2012, 12:40:43 AM
Well I'm using SketchUp to get the big stuff out of the way. I'm using Quark for my editor and it can be a pain / slow down in some instances.

As for the table being a model, I was having some issues exporting as an md3. Something about the keyframe not being set, then I set that and it gave me some other issues. I found this: http://cube.wikispaces.com/MD3+Export+From+Blender+Tutorial . I'll have to **** around some more tomorrow.
Title: Re: Block Primitives instead of Planes
Post by: kat on May 03, 2012, 02:20:39 AM
What version of Blender are you using? That's an old tutorial so you'll probably need to drop back to that one (2.45) to get the most from that process - iirc you'll need to set at least a single frame for export otherwise the process can't produce a full MD3. Does Quark support other formats? ASE?
Title: Re: Block Primitives instead of Planes
Post by: ellisgl on May 03, 2012, 03:35:04 AM
I'm using 2.36 and yes Quark can do ASE models. So I'll try that out.
Title: Re: Block Primitives instead of Planes
Post by: ellisgl on May 03, 2012, 03:34:33 PM
Quick question, is there a script that will take all everything that is selected and convert to quad and remove doubles? Doing each one by hands is a pita.
Title: Re: Block Primitives instead of Planes
Post by: kat on May 03, 2012, 03:48:37 PM
Both re-Quading and RemDoubs have to be done in Edit mode because of the way Blender works so the only way to do it on everything in one go would be to join all your meshes together (which you want to avoid really), or at least join objects belonging to the same item - the table top and legs joined together for example. So in a word, no, or at least not that I'm aware.
Title: Re: Block Primitives instead of Planes
Post by: ellisgl on May 03, 2012, 04:20:35 PM
So the next question is could it be scripted with the Python?
Loop through each selected object, select it, switch to edit mode, select all vertex, run tri 2 quads and then remove doubles?
Title: Re: Block Primitives instead of Planes
Post by: kat on May 03, 2012, 04:42:41 PM
The principle is basically a batch command parsing a couple of functions so in theory it's possible. However, as you'd be dealing with datablocks at different levels - 'Object' datablock select, mode switch, function execute - it may be more complex to script up than one would expect.

Keep in mind that converting Tris to Quads doesn't always product optimal results when done automatically, the formation of Quads is based on the way tris are orientated to each other which can result in defunct Quads, so you always need to check meshes for that any way.
Title: Re: Block Primitives instead of Planes
Post by: ellisgl on May 03, 2012, 08:05:20 PM
Here's what I came up with:
Code: [Select]
import bpy

#Make sure we are in Object Mode
bpy.ops.object.mode_set(mode='OBJECT')

#Loop through selected objects
for obj in bpy.context.selected_objects:
    #If the object is a mesh
    if obj.type == 'MESH':
        bpy.context.scene.objects.active = obj
        bpy.ops.object.editmode_toggle()
        bpy.ops.mesh.select_all(action = 'SELECT')
        bpy.ops.mesh.tris_convert_to_quads()
        bpy.ops.mesh.remove_doubles()
        bpy.ops.object.editmode_toggle()

bpy.ops.object.select_all(action = 'SELECT')
Title: Re: Block Primitives instead of Planes
Post by: kat on May 03, 2012, 11:08:01 PM
Simple bit of genius that ;)

Saved as a *.py file, loaded into the Text Editor and run with Alt+P.

From a practical point of view you might want to include a simple yes/no/all confirmation just in case you have situations where you don't want to convert everything in the scene. Other than that, Smoothing is kept where the Edge Split modifier is in place and edges marked so that's good.
Title: Re: Block Primitives instead of Planes
Post by: ellisgl on May 04, 2012, 04:20:27 AM
Well it only works on objects that are selected before running the script, so it might be redundant. Not too shabby for my first real python script and my first blender api interaction. Of course I will need to learn about how python does OOP and then figure out how this register unregister thing works.

This map that I'm working on will probably be the first one I've completed ever (I've been playing around with mapping since Quake 1).