def draw(self): if not self.show: return ImGui.SetNextWindowSize(ImGui.ImVec2(500, 400), ImGui.ImGuiCond_FirstUseEver) self.show = ImGui.Begin("Log", self.show)[1] ImGui.PushFont(self.font) for msg, lvl in self.items: if lvl == 4: ImGui.PushStyleColor(ImGui.ImGuiCol_Text, ImGui.ImVec4(1, 0.4, 0.4, 1)) elif lvl == 3: ImGui.PushStyleColor(ImGui.ImGuiCol_Text, ImGui.ImVec4(1, 0.8, 0.4, 1)) ImGui.TextWrapped(msg) if lvl > 2: ImGui.PopStyleColor() ImGui.PopFont() ImGui.End()
def preRenderTargetUpdate(self, evt): if not self.app.cam.getViewport().getOverlaysEnabled(): return Ogre.Overlay.ImGuiOverlay.NewFrame() entity = self.app.entity if entity is None: self.draw_loading() return if ImGui.BeginMainMenuBar(): if ImGui.BeginMenu("File"): if ImGui.MenuItem("Select Renderer"): self.app.getRoot().queueEndRendering() self.app.restart = True if ImGui.MenuItem("Save Screenshot", "P"): self.app._save_screenshot() if ImGui.MenuItem("Quit", "Esc"): self.app.getRoot().queueEndRendering() ImGui.EndMenu() if ImGui.BeginMenu("View"): enode = entity.getParentSceneNode() if ImGui.MenuItem("Show Axes", "A", self.app.axes_visible): self.app._toggle_axes() if ImGui.MenuItem("Show Bounding Box", "B", enode.getShowBoundingBox()): self.app._toggle_bbox() if entity.hasSkeleton() and ImGui.MenuItem( "Show Skeleton", None, entity.getDisplaySkeleton()): entity.setDisplaySkeleton(not entity.getDisplaySkeleton()) ImGui.EndMenu() if ImGui.BeginMenu("Help"): if ImGui.MenuItem("Metrics", None, self.show_metrics): self.show_metrics = not self.show_metrics if ImGui.MenuItem("Log"): self.logwin.show = True if ImGui.MenuItem("About"): self.show_about = True ImGui.EndMenu() ImGui.EndMainMenuBar() if self.show_about: self.draw_about() if self.show_metrics: self.draw_metrics() # Mesh Info Sidebar mesh = entity.getMesh() ImGui.SetNextWindowSize(ImGui.ImVec2(300, 500), ImGui.ImGuiCond_FirstUseEver) ImGui.SetNextWindowPos(ImGui.ImVec2(0, 30)) flags = ImGui.ImGuiWindowFlags_NoTitleBar | ImGui.ImGuiWindowFlags_NoMove ImGui.Begin("MeshProps", None, flags) ImGui.Text(mesh.getName()) highlight = -1 if ImGui.CollapsingHeader("Geometry"): if mesh.sharedVertexData: if ImGui.TreeNode("Shared Vertices: {}".format( mesh.sharedVertexData.vertexCount)): show_vertex_decl(mesh.sharedVertexData.vertexDeclaration) ImGui.TreePop() else: ImGui.Text("Shared Vertices: None") for i, sm in enumerate(mesh.getSubMeshes()): submesh_details = ImGui.TreeNode("SubMesh #{}".format(i)) if ImGui.IsItemHovered(): highlight = i if submesh_details: ImGui.BulletText("Material: {}".format( sm.getMaterialName())) op = ROP2STR[ sm. operationType] if sm.operationType <= 6 else "Control Points" ImGui.BulletText("Operation: {}".format(op)) if sm.indexData.indexCount: bits = sm.indexData.indexBuffer.getIndexSize() * 8 ImGui.BulletText("Indices: {} ({} bit)".format( sm.indexData.indexCount, bits)) else: ImGui.BulletText("Indices: None") if sm.vertexData: if ImGui.TreeNode("Vertices: {}".format( sm.vertexData.vertexCount)): show_vertex_decl(sm.vertexData.vertexDeclaration) ImGui.TreePop() else: ImGui.BulletText("Vertices: shared") ImGui.TreePop() if self.highlighted > -1: entity.getSubEntities()[self.highlighted].setMaterialName( self.orig_mat) if highlight > -1: self.orig_mat = entity.getSubEntities()[highlight].getMaterial( ).getName() entity.getSubEntities()[highlight].setMaterial( self.app.highlight_mat) self.highlighted = highlight animations = entity.getAllAnimationStates() if animations is not None and ImGui.CollapsingHeader("Animations"): controller_mgr = Ogre.ControllerManager.getSingleton() if entity.hasSkeleton(): ImGui.Text("Skeleton: {}".format(mesh.getSkeletonName())) # self.entity.setUpdateBoundingBoxFromSkeleton(True) if mesh.hasVertexAnimation(): ImGui.Text("Vertex Animations") for name, astate in animations.getAnimationStates().items(): if ImGui.TreeNode(name): if astate.getEnabled(): if ImGui.Button("Reset"): astate.setEnabled(False) astate.setTimePosition(0) if name in self.app.active_controllers: controller_mgr.destroyController( self.app.active_controllers[name]) elif ImGui.Button("Play"): astate.setEnabled(True) self.app.active_controllers[ name] = controller_mgr.createFrameTimePassthroughController( Ogre.AnimationStateControllerValue.create( astate, True)) changed = False if astate.getLength() > 0: ImGui.SameLine() changed, value = ImGui.SliderFloat( "", astate.getTimePosition(), 0, astate.getLength(), "%.3fs") if changed: astate.setEnabled(True) astate.setTimePosition(value) ImGui.TreePop() lod_count = mesh.getNumLodLevels() if lod_count > 1 and ImGui.CollapsingHeader("LOD levels"): entity.setMeshLodBias(1) # reset LOD override strategy = mesh.getLodStrategy().getName() curr_idx = entity.getCurrentLodIndex() ImGui.Text("Strategy: {}".format(strategy)) for i in range(lod_count): txt = "Base Mesh" if i == 0 else "Level {}: {:.2f}".format( i, mesh.getLodLevel(i).userValue) ImGui.Bullet() ImGui.Selectable(txt, i == curr_idx) if ImGui.IsItemHovered(): # force this LOD level entity.setMeshLodBias(1, i, i) if ImGui.CollapsingHeader("Bounds"): bounds = mesh.getBounds() s = bounds.getSize() ImGui.BulletText("Size: {:.2f}, {:.2f}, {:.2f}".format( s[0], s[1], s[2])) c = bounds.getCenter() ImGui.BulletText("Center: {:.2f}, {:.2f}, {:.2f}".format( c[0], c[1], c[2])) ImGui.BulletText("Radius: {:.2f}".format( mesh.getBoundingSphereRadius())) ImGui.End() self.logwin.draw()