AssetGen addon (old thread)

Hi Linko, you can try this way:

Add the constraint
bpy.ops.object.constraint_add(type=‘COPY_TRANSFORMS’)

Set the target
bpy.context.object.constraints[“constraint name”].target = bpy.data.objects[“object name”]

Apply visual transform to the object
bpy.ops.object.visual_transform_apply()

And then delete the constraint
bpy.ops.constraint.delete()

Linko i made a little dirty script
when you run the script, appears in the tools panel under the name “Raven test tools”
then, select the rotated object, select the other object and click the “Copy transforms” button in the T panel


bl_info = {
    "name": "Raven TestTools",
    "author": "RavenFactory",
    "version": (0, 0, 1),
    "blender": (2, 76, 2),
    "location": "View3D",
    "description": "Test Tools",
    "category": "Test"
}
import bpy
class copy_transforms_to_selected(bpy.types.Operator):
    bl_idname = "object.cttp"
    bl_label = "Copy transforms to selected element"
    bl_description = ""
    bl_options = {'REGISTER', 'UNDO'}
    def execute(self, context):
        use_global_undo = context.user_preferences.edit.use_global_undo
        context.user_preferences.edit.use_global_undo = True
        active_object = bpy.context.active_object
        
        constraint = active_object.constraints.new('COPY_TRANSFORMS')
        constraint.target = bpy.context.selected_objects[1]
        bpy.ops.object.visual_transform_apply()
        bpy.context.active_object.constraints.remove(constraint) 
        return {'FINISHED'}
    
class raven_test_tools(bpy.types.Panel):

    bl_label = "Raven Test Tools"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_category = 'Raven'
    
    def draw(self, context):
        layout = self.layout
        col = layout.column()
        row = layout.row(align=True)
        
        col.label(text = "Copy transforms")
        col = layout.column(align=True)
        col.operator("object.cttp", text="Copy Transforms")
                 
def register():
    bpy.utils.register_class(copy_transforms_to_selected)
    bpy.utils.register_class(raven_test_tools)
def unregister():
    bpy.utils.unregister_class(copy_transforms_to_selected)
    bpy.utils.unregister_class(raven_test_tools)
if __name__ == "__main__":
    register()

KINjO thank you for the quick answer and help. I have tried your code and it doesn’t compile at the first command, i have selected two objects:


import bpy

bpy.ops.object.constraint_add(type='COPY_TRANSFORM S')

bpy.context.object.constraints["constraint name"].target = bpy.data.objects["object name"]

bpy.ops.object.visual_transform_apply()

bpy.ops.constraint.delete()

Update:

I have replaced the Clean Topology script by Generate LP (low poly) to create an hard surface game asset ready in one click. It applies the modifier(s), join the selected mesh to the active selection, center the mesh, remove the doubles, remove the previous seams, apply the coordinates, remove the ngons, add seams, cut it by half, unfold half of it to maximize the texel density, resymetrize it, applies a smooth shading and an edge split modifier.

Demonstration after clicking this new tool with a massive ngon (i did just one click, nothing else, my ngon is fixed and my entire mesh is perfectly unfolded):


Source:

#Generate LP

import bpy

bpy.ops.object.mode_set(mode = 'OBJECT')

bpy.ops.object.convert(target='MESH')

bpy.ops.object.join()

bpy.context.object.location[0] = 0
bpy.ops.object.transform_apply(location=False, rotation=True, scale=False)

bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.mesh.select_all(action = 'SELECT')

bpy.ops.mesh.remove_doubles()

bpy.ops.mesh.quads_convert_to_tris()
bpy.ops.mesh.tris_convert_to_quads()


bpy.ops.mesh.select_mode(type="EDGE")
bpy.ops.mesh.mark_seam(clear=True)


bpy.ops.mesh.select_all(action = 'DESELECT')
bpy.ops.mesh.edges_select_sharp(sharpness=0.525344)
bpy.ops.mesh.mark_seam(clear=False)

bpy.ops.mesh.select_all(action = 'SELECT')

bpy.ops.mesh.bisect(plane_co=(0, 0, 0), plane_no=(1, 0, 0), clear_inner=True, clear_outer=False, xstart=376, xend=381, ystart=133, yend=62)

bpy.ops.mesh.mark_seam(clear=False)
bpy.ops.mesh.select_all(action = 'SELECT')
bpy.ops.uv.unwrap(method='ANGLE_BASED', margin=0.02)
bpy.ops.mesh.select_all(action = 'DESELECT')

bpy.ops.object.mode_set(mode = 'OBJECT')
bpy.ops.object.shade_smooth()

bpy.ops.object.modifier_add(type='MIRROR')
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Mirror")

bpy.ops.object.modifier_add(type='EDGE_SPLIT')
bpy.context.object.modifiers["EdgeSplit"].split_angle = 0.525344

Fix: Dark Blender Theme updated

Hi Linko, this one is working for me.
you can install as an addon or run as text script.


bl_info = {
    "name": "Raven TestTools",
    "author": "RavenFactory",
    "version": (0, 0, 2),
    "blender": (2, 76, 2),
    "location": "View3D",
    "description": "Test Tools",
    "category": "Test"
}
import bpy
class copy_transforms_to_selected(bpy.types.Operator):
    bl_idname = "object.cttp"
    bl_label = "Copy transforms to selected element"
    bl_description = ""
    bl_options = {'REGISTER', 'UNDO'}
    def execute(self, context):
        use_global_undo = context.user_preferences.edit.use_global_undo
        context.user_preferences.edit.use_global_undo = True
        active_object = bpy.context.active_object
        
        constraint = active_object.constraints.new('COPY_TRANSFORMS')
        if bpy.context.selected_objects[0] == bpy.context.active_object:
            constraint.target = bpy.context.selected_objects[1]
        else:
            constraint.target = bpy.context.selected_objects[0]
        bpy.ops.object.visual_transform_apply()
        bpy.context.active_object.constraints.remove(constraint) 
        return {'FINISHED'}
    
class raven_test_tools(bpy.types.Panel):

    bl_label = "Raven Test Tools"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_category = 'Raven'
    
    def draw(self, context):
        layout = self.layout
        col = layout.column()
        row = layout.row(align=True)
        
        col.label(text = "Copy transforms")
        col = layout.column(align=True)
        col.operator("object.cttp", text="Copy Transforms")
                 
def register():
    bpy.utils.register_class(copy_transforms_to_selected)
    bpy.utils.register_class(raven_test_tools)
def unregister():
    bpy.utils.unregister_class(copy_transforms_to_selected)
    bpy.utils.unregister_class(raven_test_tools)
if __name__ == "__main__":
    register()

Hi there, Dark Blender is really awesome, i’ve got just one problem, i can’t find the quick game uv file. :confused:
I downloaded the zip several times to test but, nope, it isn’t there…

Edit : nevermind, i’ve just forget to read everything :’( but you’re awesome man

Hello
I could post in script format the One-Click game UV Mapping! (author Cancer and the Clean Topology script by Generate LP (low poly)
so I can use the normal blender, it would be helpful

KINjO: i have imported your new script it doesn’t compile:


MagicalPaladin: i must edit the first page, i have replaced it by the Auto Seam script. I will create a panel with every scripts. Merci au passage. :slight_smile:

raziel_henzo: you can get the Quick Game UVs script here: /uploads/default/original/4X/a/7/a/a7a1127d15a17463c320c75f1a5b8a860b513aba.zip but i suggest you to use the Auto Seam script instead it runs faster, just create a text file in Blender and launch it:

#Auto Seam

import bpy

bpy.ops.object.mode_set(mode = 'OBJECT')

for obj in bpy.context.selected_objects:

    bpy.context.scene.objects.active = obj
    
    bpy.ops.object.mode_set(mode = 'EDIT')
    bpy.ops.mesh.select_mode(type="EDGE")
    bpy.ops.mesh.select_all(action = 'DESELECT')
    bpy.ops.mesh.edges_select_sharp(sharpness=0.525344)
    bpy.ops.mesh.mark_seam(clear=False)
    bpy.ops.mesh.select_all(action = 'SELECT')
    
    bpy.ops.mesh.remove_doubles()

    bpy.ops.uv.unwrap(method='ANGLE_BASED', margin=0.02)
    bpy.ops.mesh.select_all(action = 'DESELECT')
    bpy.ops.object.mode_set(mode = 'OBJECT')

I have posted the source of Generate LP in my previous post.

Update:

Extract Mesh script added, it will help you to create accessories and objects, it works a bit like the Extract tool of ZBrush, the difference is that you can edit the thickness in real time with Blender.

To use it:

  • (optionnal) Use dyntopo to create more geometry where you want the mesh extracted
  • Enter in edit mode and use the Circle select (c) to select the faces then click the script Extract Mesh.

A Solidify modifier will be applied, tweak the desired thickness in the modifier then apply it. You can after inflate your new mesh by selecting it and doing alt + s to move each face along their normal.
If you want you can use the Decimate modifier, the Generate LP (to symetrize it and/or unfold it)


Source:

#Extract Mesh

import bpy

bpy.ops.object.mode_set(mode = 'OBJECT')
bpy.ops.object.duplicate()

bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.mesh.select_all(action='INVERT')
bpy.ops.mesh.delete(type='FACE')
bpy.ops.object.mode_set(mode = 'OBJECT')
bpy.ops.object.modifier_add(type='SOLIDIFY')
bpy.context.object.modifiers["Solidify"].thickness = -0.1

How it works:

  • it goes in Object mode then duplicate your polygon
  • it enters in edit mode, it invert the face you have selected to remove the rest.
  • it goes in Object mode and applies a Solidify modifiers with a negative thickness to make the extrusion goes out (when the value is negative Blender clean the normal anyway you wont have to do anything)

Thanks !!!

yeah now i can see the problem, for some reason when i paste the code in the forum some random spaces are added, i don’t know why.
Anyways, i edited and corrected the code in my previous post, then copied and pasted in a new text file in Blender to test it and it works.
PM if you need.

The error on Line 27 (and two more) are corrected:

bpy.context.active_object.constraints.remove(<b>const raint</b>) 

to
bpy.context.active_object.constraints.remove(constraint)

This is amazing :smiley:

Can you make a AutoMesher that also pays attention to deformation zones / bone weight changes?

Can we make and rig a actor and then export a UV unwrapped, baked, Rigged, low poly version 1 click

I would joygasm.

KinjO it works now i am adding the addon. :slight_smile: It’s in the n menu though, but i think it’s better this way to not have too much options in the t menu. Can i use your script as a base to include my scripts?

BluePrintRandom: for the first script there is the decimation modifiers with the Vertex Group option, to share the vertex group with your weight of the bones, the problem is that each bone has it’s own vertex group.

For the second i’ll see if i can create a script to Unwrap, correct ngons, optimize the texels, bake the Normal, AO, and Bent normal map in a relative path folder from two selected meshes.

Update
- Generate LP now rebuild the topology (non destructive!)
I did some tests, if i switch to edge mode, select the sharp edges at 30.1, invert the selection, use the limited disolve (the polygon will stay attached, and the awesome software that is Blender will not dissolve edges that impact a lot the geometry, for example an edge that pushes the geometry will remain) and run the Generate LP script the faces will be reorganized and the extra edges not needed removed, the ngons fixed. So i have gathered the two techniques in the Generate LP script.

When to use it? All the time for hard surface models:

  • applies the modifier, remove the doubles, clear the normales
  • optimize your polycount, remove your ngons, create edges between booleans
  • add seams automatically
  • auto unwrap your model while optimizing your texel density for your bake/texture/painting
  • Smooth your model and applies an edge split modifier

Demonstration (as you can see Blender keep the edges at the extremity that deform the shapes, that’s why this technique is non-destructive):


Model ready to be exported in your game in one click!

Also if i use the bisect tool in face mode i am able to delete the faces on the symmetrical axis, then i redo a bisect in edge mode to mark the seams. The script also correct your normals.


If you don’t want your model to be cut by half move it to the right along the x axis, apply the location (Ctrl + a) use Generate LP then Cut Half.

You can also play with the subdivision and the extrude tool to make holes, use booleans everywhere, Dark Blender will clean the mesh and you will still be able to generate a High Poly from the new low poly (doesn’t work everytime):


Source:

#Generate LP

import bpy

bpy.ops.object.mode_set(mode= 'OBJECT')

bpy.ops.object.convert(target='MESH')

bpy.ops.object.join()

bpy.context.object.location[0]= 0
bpy.ops.object.transform_apply(location=False,rotation=True, scale=False)

bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.mesh.reveal()
bpy.ops.mesh.select_mode(type="EDGE")
bpy.ops.mesh.select_all(action = 'DESELECT')
bpy.ops.mesh.edges_select_sharp(sharpness=0.525344)
bpy.ops.mesh.select_all(action='INVERT')

bpy.ops.mesh.dissolve_limited()

bpy.ops.object.mode_set(mode= 'EDIT')
bpy.ops.mesh.select_all(action= 'SELECT')

bpy.ops.mesh.remove_doubles()
bpy.ops.mesh.normals_make_consistent(inside=False)

bpy.ops.mesh.quads_convert_to_tris()
bpy.ops.mesh.tris_convert_to_quads()

bpy.ops.mesh.select_mode(type="EDGE")
bpy.ops.mesh.mark_seam(clear=True)

bpy.ops.mesh.select_all(action= 'DESELECT')
bpy.ops.mesh.edges_select_sharp(sharpness=0.525344)
bpy.ops.mesh.mark_seam(clear=False)

bpy.ops.mesh.select_all(action= 'SELECT')

bpy.ops.mesh.bisect(plane_co=(0,0, 0), plane_no=(1, 0, 0), clear_inner=True, clear_outer=False,xstart=376, xend=381, ystart=133, yend=62)

bpy.ops.mesh.delete(type='FACE')

bpy.ops.mesh.select_all(action= 'SELECT')

bpy.ops.mesh.bisect(plane_co=(0,0, 0), plane_no=(1, 0, 0), clear_inner=True, clear_outer=False,xstart=376, xend=381, ystart=133, yend=62)

bpy.ops.mesh.mark_seam(clear=False)
bpy.ops.mesh.select_all(action= 'SELECT')
bpy.ops.uv.unwrap(method='ANGLE_BASED',margin=0.02)
bpy.ops.mesh.select_all(action= 'DESELECT')

bpy.ops.object.mode_set(mode= 'OBJECT')
bpy.ops.object.shade_smooth()

bpy.ops.object.modifier_add(type='MIRROR')
bpy.ops.object.modifier_apply(apply_as='DATA',modifier="Mirror")

bpy.ops.object.modifier_add(type='EDGE_SPLIT')
bpy.context.object.modifiers["EdgeSplit"].split_angle= 0.525344
  • Script from KINjO to match the transforms of another mesh has been added in the Addon folder.

BUG: with Select > Hard Edges some edges aren’t selected

Yesssssssss!!!

Thank you guys. :slight_smile:

Cancer: i don’t know a lot about Lightmap, when i try to make my own i always get the dark lines at the separation between two meshes. I need to learn how it works.

I use shortcuts all the time for me they are faster and the pie replace some shortcuts of Blender i don’t work as fast when i enable it. That’s why i prefer Blender over Maya. But you can reuse my scripts to create a pie and post it here, i personally prefer to build a pop-up menu or a menu in the panel (i don’t know how to do that yet i focus on creating useful scripts for game creation) and bind shortcuts to the most used scripts.

I am currently watching tutorials and i add a script everytime i see a game artist struggling to make/fix something.

Update:
(i will add the scrips on a pop-up menu or panel with shortcut later and will work on the script suggested by @BluePrintRandom to bake and export automatically a normal, ambiant and bent map at the same time)

Add pipe script added
Blender will add a curve where you click (it doesn’t do that by default) and will set a bevel with an optimized curve resolution (Alt + s to adjust the radius):


#Add pipe

import bpy

bpy.ops.curve.primitive_bezier_curve_add(radius=1, view_align=False, enter_editmode=False, location=(0, 0, 0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
bpy.context.object.data.resolution_u = 10
bpy.context.object.data.fill_mode = 'FULL'
bpy.context.object.data.bevel_depth = 0.1
bpy.context.object.data.bevel_resolution = 4

bpy.ops.object.origin_set(type='ORIGIN_CURSOR')
bpy.ops.object.origin_set(type='GEOMETRY_ORIGIN')

Fill hole script added
Sometimes Dyntopo makes holes or you can forget to close some while modeling. This script will fill every holes of your model and works on multiple selection.
Caution if you use the script on an open polygon like a plane or terrain will will generate a face at the border that you will have to delete. You can fix a terrain with a remesh modifier.


#Fill Holes

import bpy

bpy.ops.object.mode_set(mode = 'OBJECT')

for obj in bpy.context.selected_objects:

    bpy.context.scene.objects.active = obj
    
    bpy.ops.object.mode_set(mode = 'EDIT')
    bpy.ops.mesh.select_all(action= 'DESELECT')
    bpy.ops.mesh.select_mode(type="EDGE")
    bpy.ops.mesh.select_non_manifold()
    bpy.ops.mesh.edge_face_add()

    bpy.ops.object.mode_set(mode = 'OBJECT')

How can i apply an Emboss filter in the Blender Compositor ? I need it to generate a Greyscale.

Yeah, a pop-up menu (that stays open until you close it) attached to a hotkey sounds a lot better to me, I’ve never really liked pie menu’s either now that I think about it.

Hi Linko, i’m glad to help! Do whatever you want with the script.

Thanks and Keep going with this Blender setup, is really awesome.

KINjO: thank you. :slight_smile:

Introducing Mesh Factory (WIP)

In Hard Surface Modeling some shapes are hard to achieve, Dark Blender has a layer splitted in different parts:

  • One with Base Meshes with modifiers pre-applied to make special shapes easily (panels, holes, etc).
  • A Kit Bashing area with screws and part to snap on your model
  • A bank of floating meshes to add on top of your model


Base Meshes currently available:

  • Basic cube unfolded
  • Strap generator with a screw modifier and subsurf applied, once it’s setup you can sculpt on it and use it for an RPG weapon
  • Bullet holes on a cylinder that use a boolean modifier, edit the shape and the array repetition then press Generate LP to have your model ready
  • Panel Generator to make sci-fi wall, patterns

The center point is your craft area, grab the parts you want to build complex meshes.

Demonstration of the Bullet holes base mesh after clicking on Generate LP (unfolded and optimized automatically):


Fixes:

  • the kit bashing screws have been flatten to avoid deformations on the normal map
  • generate LP correct the normals at the end after doing a mirror and select the edges correctly by using the edge split modifier (edge sharp doesn’t select everything)
#Generate LP

import bpy


bpy.ops.object.mode_set(mode= 'OBJECT')


bpy.ops.object.convert(target='MESH')


bpy.ops.object.join()


bpy.context.object.location[0]= 0
bpy.ops.object.transform_apply(location=False,rotation=True, scale=False)




bpy.ops.object.modifier_add(type='EDGE_SPLIT')
bpy.context.object.modifiers["EdgeSplit"].split_angle = 0.525344
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="EdgeSplit")


bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.mesh.reveal()
bpy.ops.mesh.select_mode(type="EDGE")
bpy.ops.mesh.select_all(action= 'SELECT')


bpy.ops.mesh.region_to_loop()
bpy.ops.mesh.mark_seam(clear=False)


bpy.ops.mesh.select_all(action= 'SELECT')
bpy.ops.mesh.dissolve_limited()


bpy.ops.mesh.quads_convert_to_tris()
bpy.ops.mesh.tris_convert_to_quads()


bpy.ops.mesh.remove_doubles()


bpy.ops.mesh.bisect(plane_co=(0,0, 0), plane_no=(1, 0, 0), clear_inner=True, clear_outer=False,xstart=376, xend=381, ystart=133, yend=62)


bpy.ops.mesh.delete(type='FACE')


bpy.ops.mesh.select_all(action= 'SELECT')


bpy.ops.mesh.bisect(plane_co=(0,0, 0), plane_no=(1, 0, 0), clear_inner=True, clear_outer=False,xstart=376, xend=381, ystart=133, yend=62)
bpy.ops.mesh.mark_seam(clear=False)


bpy.ops.mesh.select_all(action= 'SELECT')
bpy.ops.uv.unwrap(method='ANGLE_BASED',margin=0.02)
bpy.ops.mesh.select_all(action= 'DESELECT')


bpy.ops.object.mode_set(mode= 'OBJECT')
bpy.ops.object.shade_smooth()


bpy.ops.object.modifier_add(type='MIRROR')
bpy.ops.object.modifier_apply(apply_as='DATA',modifier="Mirror")


bpy.ops.object.modifier_add(type='EDGE_SPLIT')
bpy.context.object.modifiers["EdgeSplit"].split_angle= 0.525344


bpy.ops.object.mode_set(mode= 'EDIT')
bpy.ops.mesh.select_all(action= 'SELECT')
bpy.ops.mesh.normals_make_consistent(inside=False)
bpy.ops.mesh.select_all(action= 'DESELECT')

This addon is very very cool


https://youtu.be/FVpcTnLQJ5s

It’s a cool Addon thank you for sharing it. :slight_smile:

I hope that the features from this addon and the tweaks on Dark Blender will help the official Blender to improve especially the 2.8.

Update:

  • I have added a file called “Windows on top with Ctrl + Space” once you launch it (need to launch it at each restart) you can pin your window(s) but it only works on Windows. I will add a file to make the windows transparent. The Modifiers are launched in pop-up.

  • Brush radius for sculpting disabled because the smooth brush and flatten works better and it’s easier to create motifs with the strip brush.

  • Y mirror script added, X and Y mirror applies a bisect first.

  • UI slightly reorganized

One tool blender does not have but all the parts are laying around,

is a system to create sprite sheets AND 2.D sprite sheets with ‘angle strips’

So we can get Freestyle NPR into a game engine in like 4 steps

Make model and animation
Generate sprite sheet
import images

about script in game, (for instance bge)

It would be very handy to have a ‘Sprint actuator’ in many engines (cough bge)

I think you could start with Spricle, or spritify at it’s core.

where there is some standard way to encode where each animation is in the sheet and how long it is

then

if keypress----------and----------(sprite actuator - play Action1 - loop )

Basically a copy of the armature action system, but for 2d and 2.5 D.

what do I mean by autogenerate 2.5?

you layout all the actors actions in a strip from 0 -> end frame and then a script renders pre defined angles,

making a game object that changes sprites based on the orientation to the camera

(side sprite when you see it from the side etc.)

then get a duplicate setup for unity, godot, ue4 and ???

‘Sprite sheet generator’

2.D action actuator

Thanks for all you have done so far with dark blender
:smiley: