class TextController(avango.script.Script): FocusNode = avango.gua.SFNode() def __init__(self): self.super(TextController).__init__() avango.gua.load_materials_from("data/materials/font") self.TextNode = avango.gua.nodes.TransformNode(Name = "TextDisplay") self.Label_ = TextField() self.Label_.my_constructor(self.TextNode) @field_has_changed(FocusNode) def focus_node_changed(self): if not self.FocusNode.value == None: self.Label_.sf_text.value = self.FocusNode.value.Path.value
def start(): ##initializing scene ------------------- graph = avango.gua.nodes.SceneGraph( Name = "scenegraph" ) ## Viewing Setup screen = avango.gua.nodes.ScreenNode( Name = "screen", Width = 1.6, Height = 0.9, Transform = avango.gua.make_trans_mat(0.0, 0.0, -2.5) ) eye = avango.gua.nodes.TransformNode( Name = "eye", Transform = avango.gua.make_trans_mat(0.0, 0.0, 7.5) ) eye.Children.value = [screen] graph.Root.value.Children.value.append(eye) camera = avango.gua.nodes.Camera( LeftEye = "/eye", RightEye = "/eye", LeftScreen = "/eye/screen", RightScreen = "/eye/screen", SceneGraph = "scenegraph" ) window = avango.gua.nodes.Window( Size = size, LeftResolution = size ) pipe = avango.gua.nodes.Pipeline( Camera = camera, Window = window, EnableSsao = False, SsaoIntensity = 0.5, LeftResolution = size, EnableRayDisplay = False, EnableFPSDisplay = False, EnableBackfaceCulling = False, NearClip = 0.0001 ) # pipe.BackgroundTexture.value = "data/textures/skymap.jpg" # pipe.BackgroundMode.value = avango.gua.BackgroundMode.SKYMAP_TEXTURE # ## Transform Test # TMtest = avango.gua.nodes.TransformNode(Name = "Test") # TMtest.Transform.value = avango.gua.make_scale_mat(0.1) # graph.Root.value.Children.value.append(TMtest) ## Setup visualization------------------- print treemap_tutorial.create_tutorial() root = filesystemloader.load(sys.argv[1]) TM = Treemap() TM.my_constructor(root) TM.create_scenegraph_structure() graph.Root.value.Children.value.append(TM.root_node) graph.update_cache() TM.layout() ## Setup Text text = TextField() text_transform = avango.gua.nodes.TransformNode( Name = "text_transform", # Transform = avango.gua.make_trans_mat(0.1 * (-0.8 / 2.5), 0.1 *(-0.4 / 2.5), -0.1) * avango.gua.make_scale_mat(0.03 * 0.1/2.5)) Transform = avango.gua.make_trans_mat(0.01 * (-0.8 / 2.5), 0.01 *(-0.42 / 2.5), -0.0101) * avango.gua.make_scale_mat(0.002 * 0.1/2.5) ) eye.Children.value.append(text_transform) text.my_constructor(text_transform) text.sf_text.connect_from(TM.Focuspath) ## Setup Controllers keyController = KeyController() keyController.setTreeMap(TM) navigator = Navigator() eye.Transform.connect_from(navigator.OutTransform) navigator.setTreeMap(TM) TM_Picker = Picker() TM_Picker.PickedSceneGraph.value = graph pick_ray = avango.gua.nodes.RayNode(Name = "pick_ray") pick_ray.Transform.value = avango.gua.make_trans_mat(0.0, 0.0, 0.0) * \ avango.gua.make_scale_mat(0.00001, 0.00001, 5) eye.Children.value.append(pick_ray) TM_Picker.Ray.value = pick_ray loader = avango.gua.nodes.TriMeshLoader() crosshair = loader.create_geometry_from_file( "crosshair", "data/objects/cube.obj", "data/materials/Grey_bright.gmd", avango.gua.LoaderFlags.DEFAULTS, ) crosshair.Transform.value = avango.gua.make_trans_mat(0.0, 0.0, -0.005) * \ avango.gua.make_scale_mat(0.00001) eye.Children.value.append(crosshair) navigator.setPicker(TM_Picker) ## Focus Updater focuser = FocusUpdater() focuser.setTreeMap(TM) focuser.Results.connect_from(TM_Picker.Results) Down_Picker = Picker() Down_Picker.PickedSceneGraph.value = graph pick_ray = avango.gua.nodes.RayNode(Name = "down_pick_ray") pick_ray.Transform.value = avango.gua.make_trans_mat(0.0, 0.0, 0.0) * \ avango.gua.make_rot_mat(-10, 1.0, 0.0, 0.0) * \ avango.gua.make_scale_mat(0.00001, 0.00001, 5) graph.Root.value.Children.value.append(pick_ray) Down_Picker.Ray.value = pick_ray navigator.controller3D.setDown_Picker(Down_Picker) Move_Picker = Picker() Move_Picker.PickedSceneGraph.value = graph pick_ray = avango.gua.nodes.RayNode(Name = "move_pick_ray") pick_ray.Transform.value = avango.gua.make_trans_mat(0.0, 0.0, 0.0) * \ avango.gua.make_rot_mat(0, 0.0, 1.0, 0.0) * \ avango.gua.make_scale_mat(0.00001, 0.00001, 5) graph.Root.value.Children.value.append(pick_ray) Move_Picker.Ray.value = pick_ray navigator.controller3D.setMove_Picker(Move_Picker) # # setup Reference # loader = avango.gua.nodes.TriMeshLoader() # reference_cubes = [] # for i in range(4): # reference_cubes.append( loader.create_geometry_from_file( # "reference_cube", # "data/objects/cube.obj", # "data/materials/Red.gmd", # avango.gua.LoaderFlags.DEFAULTS, # )) # reference_cubes[0].Transform.value = avango.gua.make_trans_mat(-0.5, 0 , -0.5) * avango.gua.make_scale_mat(0.11) # reference_cubes[1].Transform.value = avango.gua.make_trans_mat( 0.5, 0 , -0.5) * avango.gua.make_scale_mat(0.11) # reference_cubes[2].Transform.value = avango.gua.make_trans_mat(-0.5, 0 , 0.5) * avango.gua.make_scale_mat(0.11) # reference_cubes[3].Transform.value = avango.gua.make_trans_mat( 0.5, 0 , 0.5) * avango.gua.make_scale_mat(0.11) # graph.Root.value.Children.value.append(reference_cubes[0]) # graph.Root.value.Children.value.append(reference_cubes[1]) # graph.Root.value.Children.value.append(reference_cubes[2]) # graph.Root.value.Children.value.append(reference_cubes[3]) # Light for the Treemap # sun = avango.gua.nodes.SunLightNode( # Name = "sun", # Color = avango.gua.Color(1, 1, 1), # Transform = avango.gua.make_rot_mat(-45, 1, 0, 0), # EnableShadows = True # ) # graph.Root.value.Children.value.append(sun) light = avango.gua.nodes.PointLightNode( Name = "light", Color = avango.gua.Color(1,1,1), Transform = avango.gua.make_trans_mat(0, 3, 0) * avango.gua.make_scale_mat(5), # EnableSpecularShading = False, EnableShadows = False ) graph.Root.value.Children.value.append(light) guaVE = GuaVE() guaVE.start(locals(), globals()) viewer = avango.gua.nodes.Viewer() viewer.Pipelines.value = [pipe] viewer.SceneGraphs.value = [graph] viewer.run()
def __init__(self): self.super(TextController).__init__() avango.gua.load_materials_from("data/materials/font") self.TextNode = avango.gua.nodes.TransformNode(Name = "TextDisplay") self.Label_ = TextField() self.Label_.my_constructor(self.TextNode)