# !--------- # --- HEIGHTMAP MESH-TILE GENERATOR --- # Outputs array of 3D tiles from array of heightmap images, also handling LOD with different smoothing. # Image 'thmap_x001_y001.png' becomes 'tmesh_l##_x001_y001,obj' with 16(~8) LOD stages exported. # Make sure your OBJ(s) have object-name "terrain" and have UVs. Y is forward, Z is up # Always start new. If OBJs don't export, try saving a new .blend file. # !--------- import bpy import os import bmesh from bpy import context, data, ops # !--------- this is the mesh to operate on... file_loc = 'C:\\LDA_!\\terrain_l16.obj' # !--------- this is the image to operate from... var_hmpifile = "thmap_x001_y001.png" var_hmpimage = "C:\\LDA_!\\thmap_x001_y001.png" var_hmpipath = "C:\\LDA_!" # !--------- strength and offset... var_displace = 7.2 var_tloffset = 1,0,0 # !--------- this is the mesh to output... var_hmtofile = "tmesh_l16_x001_y001.obj" # !--------- # !--------- end of edits, except smoothing... # !--------- def update(self, context): global var_hmpifile global var_hmpimage global var_hmpipath global var_displace global var_tloffset #bpy.data.objects['terrain'].select_set(True) #current_state = bpy.data.objects['terrain'].select_get() #bpy.context.view_layer.objects.active = bpy.data.objects['terrain'] scene = bpy.context.scene scene.layers = [True] * 20 #bpy.context.space_data.grid_subdivisions = 16 bpy.ops.group.objects_remove_all() bpy.ops.object.select_all(action='DESELECT') #(none)# imported_object = bpy.ops.import_scene.obj(filepath=file_loc) obj_object = bpy.context.selected_objects[0] print('Imported name: ', obj_object.name) bpy.ops.transform.resize(value=(0.015625, 0.015625, 0.015625), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) bpy.ops.transform.rotate(value=-1.5708, axis=(0, 1, 0), constraint_axis=(True, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) bpy.ops.transform.rotate(value=-1.5708, axis=(1, 0, 0), constraint_axis=(True, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) bpy.ops.transform.rotate(value=1.5708, axis=(1, 0, 0), constraint_axis=(True, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) bpy.context.scene.objects.active = bpy.context.selected_objects[0] bpy.ops.object.select_all(action='TOGGLE') #(all)# bpy.ops.object.select_all(action='TOGGLE') #(none)# bpy.data.objects['terrain'].select = True #(1)# bpy.ops.object.editmode_toggle() #(edit-mode)# bpy.ops.object.mode_set(mode='EDIT') #(edit-mode)# bpy.ops.mesh.remove_doubles() bpy.ops.mesh.quads_convert_to_tris(quad_method='BEAUTY', ngon_method='BEAUTY') bpy.ops.object.editmode_toggle() #(object-mode)# #bpy.context.space_data.context = 'TEXTURE' bpy.data.objects['terrain'].select = True bpy.ops.texture.new() bpy.context.object.active_material.active_texture_index = 1 bpy.ops.texture.new() bpy.data.textures.new("heightmap0", type='IMAGE') ui_tex = bpy.data.textures.new('heightmap', 'IMAGE') ui_tex.image = bpy.data.images.load(var_hmpimage) bpy.context.object.active_material.active_texture_index = 1 bpy.ops.texture.new() bpy.ops.image.open(filepath=var_hmpimage, directory=var_hmpipath, files=[{"name":var_hmpifile}], relative_path=False, show_multiview=False) bpy.ops.image.open(filepath=var_hmpimage) #bpy.context.space_data.context = 'MODIFIER' bpy.data.objects['terrain'].select = True bpy.ops.object.modifier_add(type='DISPLACE') bpy.ops.texture.new() bpy.data.objects['terrain'].modifiers['Displace'].texture = bpy.data.textures['heightmap'] #bpy.context.object.modifiers["Displace"].direction = 'Z', bpy.context.object.modifiers["Displace"].texture_coords = 'UV' bpy.context.object.modifiers["Displace"].mid_level = 0 bpy.context.object.modifiers["Displace"].strength = var_displace bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Displace") bpy.ops.object.editmode_toggle() #(edit-mode)# bpy.ops.object.mode_set(mode='EDIT') #(edit-mode)# bpy.ops.mesh.select_all(action='TOGGLE') #(none)# bpy.ops.mesh.select_non_manifold() #(perimeter-vertices)# # !--------- should put forced normals here... bpy.ops.mesh.select_all(action='INVERT') #(inner-vertices)# # !--------- # !--------- increasing smoothing for higher LODs... # !--------- add more of these lines for softer (inner) results of high-LOD terrain. bpy.ops.mesh.vertices_smooth(xaxis=False, yaxis=False) bpy.ops.mesh.vertices_smooth(xaxis=False, yaxis=False) bpy.ops.mesh.vertices_smooth(xaxis=False, yaxis=False) # !--------- noise terrain for higher LODs... (0.03-0.13) bpy.ops.object.material_slot_assign() bpy.ops.transform.vertex_random(offset=0.07, uniform=0.17, normal=0.7, seed=666) bpy.ops.mesh.noise(factor=0.27) # !--------- bpy.ops.object.editmode_toggle() #(object-mode)# bpy.ops.object.visual_transform_apply() #if bpy.context.active_object is not None: bpy.context.scene.cursor_location = bpy.context.active_object.location bpy.ops.object.editmode_toggle() #(edit-mode)# #bpy.ops.view3d.snap_cursor_to_active() bpy.ops.mesh.select_all(action='TOGGLE') #(none)# bpy.ops.mesh.select_all(action='TOGGLE') #(all)# bpy.ops.mesh.sort_elements(type='CURSOR_DISTANCE', elements={'VERT'}) bpy.ops.object.material_slot_assign() bpy.ops.mesh.select_all(action='TOGGLE') #(none)# bpy.ops.mesh.select_non_manifold() #(perimeter-vertices)# #bpy.context.area.type = 'VIEW_3D' bpy.ops.view3d.snap_selected_to_grid() bpy.ops.object.editmode_toggle() #(object-mode)# bpy.ops.transform.resize(value=(1.00001, 1.00001, 1.00001), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) bpy.ops.object.transform_apply(location=True, rotation=True, scale=True) bpy.ops.object.visual_transform_apply() #bpy.context.space_data.context = 'DATA' bpy.context.object.data.use_auto_smooth = True #bpy.context.space_data.context = 'MODIFIER' bpy.ops.object.editmode_toggle() #(edit-mode)# bpy.ops.mesh.select_all(action='TOGGLE') bpy.ops.mesh.faces_shade_smooth() bpy.ops.mesh.mark_sharp(clear=True) bpy.ops.mesh.mark_sharp(clear=True, use_verts=True) bpy.ops.mesh.normals_make_consistent() #bpy.context.area.type = 'VIEW_3D' for area in bpy.context.screen.areas: if area.type == 'VIEW_3D': for region in area.regions: if region.type == 'WINDOW': override = {'area': area, 'region': region, 'edit_object': bpy.context.edit_object} bpy.ops.view3d.view_all(override) bpy.ops.view3d.snap_selected_to_grid() bpy.ops.mesh.normals_make_consistent(inside=True) bpy.ops.object.editmode_toggle() #(object-mode)# bpy.ops.object.shade_smooth() bpy.ops.transform.translate(value=(var_tloffset), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1) blend_file_path = bpy.data.filepath directory = os.path.dirname(blend_file_path) target_file = os.path.join(directory,var_hmtofile) bpy.ops.export_scene.obj(filepath=target_file) # !--------- #. #. #.
heightMap { texture = "(?:(?!\\\\)(?:.|\n))*\\\\(?:(?!\\\\)(?:.|\n))*\\\\(?:(?!\\\\)(?:.|\n))*\\\\(?:(?!_bmp)(?:.|\n))*_bmp(?:(?!\.)(?:.|\n))*\.(?:(?!")(?:.|\n))*" }[\r\n]+ heightScale \= (?:(?!(?:\r\n?|\n\r?))(?:.|\n))*(?:\r\n?|\n\r?)[\r\n]+ displacementTechnique \= (?:(?!(?:\r\n?|\n\r?))(?:.|\n))*(?:\r\n?|\n\r?)[\r\n]+ diffuse6Map { texture \= "(?:(?!\\\\)(?:.|\n))*\\\\(?:(?!\\\\)(?:.|\n))*\\\\(?:(?!\\\\)(?:.|\n))*\\\\(?:(?!_occ)(?:.|\n))*_occ(?:(?!\.)(?:.|\n))*\.(?:(?!"(?:\r\n?|\n\r?))(?:.|\n))*"(?:\r\n?|\n\r?) }[\r\n]+ diffuse(?:(?!Map)(?:.|\n))*Map { texture \= "(?:(?!\\\\)(?:.|\n))*\\\\(?:(?!\\\\detail\\\\detaili_)(?:.|\n))*\\\\detail\\\\detaili_(?:(?!\.)(?:.|\n))*\.(?:(?!")(?:.|\n))*" transform { scale \= (?:(?! )(?:.|\n))* (?:(?! )(?:.|\n))* } }[\r\n]+
textures/filter/cgtxtrsnwstndcl1 { translucent noselfshadow qer_editorimage textures/filter/cgtxtrsnwstndcl1.jpg { blend gl_dst_color, gl_zero map textures/filter/cgtxtrsnwstndcl1.jpg } } _____________________(extended):- noselfshadow = translucent\r\n noselfshadow _____________________(normal):- / = l1l1l _____________________(normal):- . = 0O0 _____________________(regex):- (^ diffuseMap [A-Za-z0-9]+$) = \1\r\n\1 _____________________(extended):- noselfshadow\r\n diffuseMap = noselfshadow\r\n qer_editorimage _____________________(extended):- jpg\r\n diffuseMap = jpg\r\n {\r\n blend gl_dst_color, gl_zero\r\n map _____________________(extended):- jpg\r\n} = jpg\r\n }\r\n} _____________________(normal):- l1l1l = / _____________________(normal):- 0O0 = .
------------------------------------------- - animate your mesh. - create a 'Dynamic' type. - attach mesh to type. - create .animationTree file:- ------------------------------------------- blocks { block Output { uin = 1 in = 100 } block Trigger { uin = 100 triggerName = "testTrigger" //name of 'trigger' referenced by code/logic. off = 200 //default 'none/idle' animation. on = 101 //animation 'test' that will be triggered. } block Animation { uin = 200 animationName = "none" speed = 1.0 } block Animation { uin = 101 animationName = "test" speed = 1.0 } } ------------------------------------------- - place region in map. ("regionName") - place entity (dynamic) in map. ("objectName") - create class in LE - Entity > Region. ("regionName") - create variable of class - Boolean > "characterInRegion". ------------------------------------------- - create method in class - ObjectOut > Script Type. characterInRegion = false; ------------------------------------------- - create method in class - ObjectIn > Script Type. characterInRegion = true; if(characterInRegion) { ( (Dynamic) Entities.Instance.GetByName( "objectName" )as Dynamic).GetFirstAnimationTree().ActivateTrigger("testTrigger); } ------------------------------------------- . . .
.
.
.
.
.
.