Пример #1
0
def main():
    '''Triggered when the game-engine is started'''
    cont = bge.logic.getCurrentController()
    player = cont.owner
    scene = bge.logic.getCurrentScene()
    keyboard = bge.logic.keyboard
    player.localPosition.y -= 0.1
    pistonpos = 0
    flag = False
    gameactu = cont.actuators['actuator1']
    try:
        pistonpos = bge.logic.globalDict['pistonpos']
        flag = True
    except KeyError:
        bge.logic.globalDict['pistonpos'] = getPistonpos()
    posdiff = abs(getPistonpos() - pistonpos)
    if posdiff < 0.0001 and flag:
        print(posdiff)
        try:
            if bge.logic.globalDict['trials'] > 1:
                calc_com()
                v = vol.volume(get_vol_positions())
                print("VOL_after::"+str(v))
                cont.activate(gameactu)
            else:
                bge.logic.globalDict['trials'] += 1
        except:
            bge.logic.globalDict['trials'] = 1
        
    bge.logic.globalDict['pistonpos'] = getPistonpos()
    if bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.DOWNARROWKEY]:
        calc_com()
Пример #2
0
         if (item.name).find("cone") >= 0:
             bpy.data.objects[item.name].game.collision_bounds_type = 'CONE'
         elif (item.name).find("cube") >= 0:
             bpy.data.objects[item.name].game.collision_bounds_type = 'BOX'
         elif (item.name).find("sphere") >= 0:
             bpy.data.objects[item.name].game.collision_bounds_type = 'SPHERE'
         else:
             bpy.data.objects[item.name].game.collision_bounds_type = 'CONVEX_HULL'
     item.select = False
     if item.name.startswith('obj_'):
         temp_dict = {}
         temp_dict['x'] = item.location.x
         temp_dict['y'] = item.location.y
         temp_dict['z'] = item.location.z                        
         temp_dict['mass'] = item.game.mass
         temp_dict['name'] = item.name
         obj_list.append(temp_dict)  
 bpy.data.objects['Cube.004'].select = True
 bpy.data.objects['Cube.004'].game.mass = 500
 bpy.data.objects['Cube.004'].select = False
 bpy.data.objects['Cylinder'].select = True
 bpy.data.objects['Cylinder'].game.mass = 150
 bpy.ops.object.origin_set(type='ORIGIN_CENTER_OF_MASS')
 com_with_obj = (COM.COM(obj_list))
 positions = get_volume_params()
 print(positions)
 print("VOL_before "+str(vol.volume(positions)))
 #print("COM_before "+str(com_with_obj))
 create_logic_bricks()
 bpy.context.scene.render.engine = 'BLENDER_GAME'
 bpy.ops.wm.blenderplayer_start()
Пример #3
0
    print "out_clipfile: ", out_clipfile

    # clip polygon from the DEM (EL RASTER ES CLIPPEADO AL AREA COORESPONDIENTE A LOS POLIGONOS)
    att_raster = arcpy.Clip_management(
        full_demfilename,
        rectangle,
        out_clipfile,
        att_polyg,
        "#",
        clipping_geometry="ClippingGeometry",
        maintain_clipping_extent="NO_MAINTAIN_EXTENT")

    #att_raster = "E:\\LowerWabash\\Indna_wtlnd\\existing_wet\\Scratch\\dem_p002"

    # call volume function to calculate DEM's volume
    volume_value = vol.volume(
        att_raster)  # <-----------------  function to calculate volume
    print "volume_value: ", round(volume_value, 2)
    list_volume.append(volume_value)

# call "add_and_populate_field" function
# set up input file. Polygon input file
inputfile = full_polyg_filename
# set up characteristics of new field
field_chr = ["vol1", "DOUBLE", "", "", "", "", "NULLABLE", "REQUIRED", ""]
# set up list of volume values to populate the new field
list_values = list_volume

# call function
volume_value = af2.add_and_populate_field(
    inputfile, field_chr, list_values)  #  <------------ Function