def __init__(self, name, worldPath, characs, color="\u001b[36m"): Entity.__init__(self, name, worldPath) self.characteristics = characs dialogueFile = os.path.abspath(GetGame.game.gameRoot + "/Dialogues/" + self.name + ".json") try: if os.path.exists(dialogueFile): with open(dialogueFile, 'r', encoding="utf-8") as f: jsonText = "".join(f.readlines()) jsonText = jsonText.replace("{username}", GetGame.game.user_name) self.dialogues = json.loads(jsonText) else: self.dialogues = None except Exception as e: print(str(e)) self.color = color
def export(scene, neuronName): ''' Run export motto neurons from blender file ''' theObjects = scene.objects i = 0 for object in theObjects: try: objType=object.getType() if objType == "Mesh": if len(object.getData().materials) > 1: if( neuroNameFromOds.__contains__(object.name) and object.name == "PVDR"):# or object.name == "URBL"):#object.getData().materials[0].name != "Motor Neuron" mm=object.getMatrix() #pydevd.settrace() print object.name entity = Entity() neuronName = object.name mesh = object.getData() for vertex in mesh.verts: ob_matrix = Mathutils.Matrix(object.getMatrix('worldspace')) mm = ob_matrix blenvert = Mathutils.Vector(vertex.co) v = blenvert * mm entity.add_vertex([round(v[0],3),round(v[1],3),round(v[2],3)]) for face in mesh.faces: cordArr = [] for i in range(len(face)): indx = mesh.verts.index(face[i]) cordArr.append(indx) entity.add_face(cordArr) entity.neuronInfo = object.getData().materials[0].name entity.findCenterOfSoma() entity.find_point() create_cell(neuronName,entity) except Exception: print "Error: object named %s has problem with accessing an attribute" % object.name badNeurons.append(object.name) continue print list(badNeurons)
def export2(): for (neuronName, v) in neuron_dict.items(): print('start %s' % neuronName) if neuronName[:7] == 'mu_bod_' or neuronName != 'VA10': # or neuronName in ('M1', 'RMED', 'PVDR', 'PVDL', 'IL1DL', 'IL1DR', 'I5', ): continue (v_list, f_list) = v entity = Entity() for vertex in v_list: v = vertex entity.add_vertex([round(v[0], 3), round(v[1], 3), round(v[2], 3)]) for face in f_list: entity.add_face(face) entity.neuronInfo = neuronName entity_to_cell(entity, neuronName)
def mesh_to_entity(mesh): entity = Entity() for vertex in mesh.vertices: v = vertex.co entity.add_vertex([round(v[0], 3), round(v[1], 3), round(v[2], 3)]) for face in mesh.tessfaces: cordArr = [] for v in face.vertices: write_log('+', v) cordArr.append(v) if len(cordArr) == 3: cordArr.append(cordArr[0]) write_log('=', cordArr) entity.add_face(cordArr) entity.neuronInfo = mesh.materials[0].name return entity
def export2(): for (neuronName, v) in neuron_dict.items(): print('start %s' % neuronName) if neuronName[:7] == 'mu_bod_' or neuronName != 'VA10': # or neuronName in ('M1', 'RMED', 'PVDR', 'PVDL', 'IL1DL', 'IL1DR', 'I5', ): continue (v_list, f_list) = v entity = Entity() for vertex in v_list: v = vertex entity.add_vertex([round(v[0],3),round(v[1],3),round(v[2],3)]) for face in f_list: entity.add_face(face) entity.neuronInfo = neuronName entity_to_cell(entity, neuronName)
def mesh_to_entity(mesh): entity = Entity() for vertex in mesh.vertices: v = vertex.co entity.add_vertex([round(v[0],3),round(v[1],3),round(v[2],3)]) for face in mesh.tessfaces: cordArr = [] for v in face.vertices: write_log('+', v) cordArr.append(v) if len(cordArr) == 3: cordArr.append(cordArr[0]) write_log('=', cordArr) entity.add_face(cordArr) entity.neuronInfo = mesh.materials[0].name return entity
def __init__(self, worldPath): Entity.__init__(self, "Rock", worldPath) pass
def __init__(self, worldPath): Entity.__init__(self, "Scissors", worldPath) pass
def __init__(self, worldPath): Entity.__init__(self, "Paper", worldPath) pass
print('===================== Program Start =====================') print('Load information about neurons name from file: %s' % neuronsFileName) if 0: # used in testing to compare to old version old_il1dl_doc = loaders.NeuroMLLoader.load('IL1DL.nml') old_il1dl_segs = old_il1dl_doc.cells[0].morphology.segments from Entity.plot import plot_segs plot_segs(old_il1dl_segs) loadNeuronsName(neuronsFileName) print('Load is finished') print('Create Neurons') for neuron_name in neurons_name: is_muscle = neuron_name.startswith('mu_') print('\tCreate Neuron: %s' % neuron_name) entity = Entity() try: is_good = get_points_and_faces(wrlFileName, neuron_name, is_muscle) except (AttributeError, IndexError): print(neuron_name) from Entity.plot import plot_faces plot_faces(entity) raise if not is_good: continue # replace_muscle(neuron_name) #from Entity.plot import plot_faces #plot_faces(entity) if is_muscle: neuron_name = convert_muscle_name(neuron_name) cell = create_muscle_cell(neuron_name)
if __name__ == '__main__': print('===================== Program Start =====================') print('Load information about neurons name from file: %s'%neuronsFileName) if 0: # used in testing to compare to old version old_il1dl_doc = loaders.NeuroMLLoader.load('IL1DL.nml') old_il1dl_segs = old_il1dl_doc.cells[0].morphology.segments from Entity.plot import plot_segs plot_segs(old_il1dl_segs) loadNeuronsName(neuronsFileName) print('Load is finished') print('Create Neurons') for neuron_name in neurons_name: is_muscle = neuron_name.startswith('mu_') print('\tCreate Neuron: %s'%neuron_name) entity = Entity() try: is_good = get_points_and_faces(wrlFileName,neuron_name, is_muscle) except (AttributeError, IndexError): print(neuron_name) from Entity.plot import plot_faces plot_faces(entity) raise if not is_good: continue # replace_muscle(neuron_name) #from Entity.plot import plot_faces #plot_faces(entity) if is_muscle: neuron_name = convert_muscle_name(neuron_name) cell = create_muscle_cell(neuron_name)