public SinbadState() { m_bQuit = false; m_pDetailsPanel = null; m_pCamera = null; m_pCameraMan = null; m_pChara = null; agents = new List <SinbadCharacterController>(); }
public bool keyPressed(KeyEvent evt) { if (!AdvancedMogreFramework.Singleton.m_pTrayMgr.isDialogVisible()) { m_pChara.injectKeyDown(evt); } if (AdvancedMogreFramework.Singleton.m_pKeyboard.IsKeyDown(KeyCode.KC_ESCAPE)) { pushAppState(findByName("PauseState")); return(true); } if (evt.key == KeyCode.KC_H || evt.key == KeyCode.KC_F1) // toggle visibility of help dialog { if (!AdvancedMogreFramework.Singleton.m_pTrayMgr.isDialogVisible() && mInfo["Help"] != "") { AdvancedMogreFramework.Singleton.m_pTrayMgr.showOkDialog("Help", mInfo["Help"]); } else { AdvancedMogreFramework.Singleton.m_pTrayMgr.closeDialog(); } } if (AdvancedMogreFramework.Singleton.m_pTrayMgr.isDialogVisible()) { return(true); // don't process any more keys if dialog is up } if (evt.key == KeyCode.KC_F) // toggle visibility of advanced frame stats { AdvancedMogreFramework.Singleton.m_pTrayMgr.toggleAdvancedFrameStats(); } else if (evt.key == KeyCode.KC_G) // toggle visibility of even rarer debugging details { if (m_pDetailsPanel.getTrayLocation() == TrayLocation.TL_NONE) { AdvancedMogreFramework.Singleton.m_pTrayMgr.moveWidgetToTray(m_pDetailsPanel, TrayLocation.TL_TOPRIGHT, 0); m_pDetailsPanel.show(); } else { AdvancedMogreFramework.Singleton.m_pTrayMgr.removeWidgetFromTray(m_pDetailsPanel); m_pDetailsPanel.hide(); } } else if (evt.key == KeyCode.KC_T) // cycle polygon rendering mode { String newVal; TextureFilterOptions tfo; uint aniso; switch (Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(m_pDetailsPanel.getParamValue(9)))) { case "B": newVal = "Trilinear"; tfo = TextureFilterOptions.TFO_TRILINEAR; aniso = 1; break; case "T": newVal = "Anisotropic"; tfo = TextureFilterOptions.TFO_ANISOTROPIC; aniso = 8; break; case "A": newVal = "None"; tfo = TextureFilterOptions.TFO_NONE; aniso = 1; break; default: newVal = "Bilinear"; tfo = TextureFilterOptions.TFO_BILINEAR; aniso = 1; break; } MaterialManager.Singleton.SetDefaultTextureFiltering(tfo); MaterialManager.Singleton.DefaultAnisotropy = aniso; m_pDetailsPanel.setParamValue(9, newVal); } else if (evt.key == KeyCode.KC_R) // cycle polygon rendering mode { String newVal; PolygonMode pm; switch (m_pCamera.PolygonMode) { case PolygonMode.PM_SOLID: newVal = "Wireframe"; pm = PolygonMode.PM_WIREFRAME; break; case PolygonMode.PM_WIREFRAME: newVal = "Points"; pm = PolygonMode.PM_POINTS; break; default: newVal = "Solid"; pm = PolygonMode.PM_SOLID; break; } m_pCamera.PolygonMode = pm; m_pDetailsPanel.setParamValue(10, newVal); } else if (evt.key == KeyCode.KC_F5) // refresh all textures { TextureManager.Singleton.ReloadAll(); } else if (evt.key == KeyCode.KC_SYSRQ) // take a screenshot { AdvancedMogreFramework.Singleton.m_pRenderWnd.WriteContentsToTimestampedFile("screenshot", ".png"); } else if (evt.key == KeyCode.KC_X) { //spawn a new agent SinbadCharacterController agent = new SinbadCharacterController(this, physicsScene, m_pCamera, m_pChara.Position, agents.Count, false); agents.Add(agent); } m_pCameraMan.injectKeyDown(evt); return(true); }
public void createScene() { // set background and some fog AdvancedMogreFramework.Singleton.m_pViewport.BackgroundColour = new ColourValue(1.0f, 1.0f, 0.8f); m_pSceneMgr.SetFog(FogMode.FOG_LINEAR, new ColourValue(1.0f, 1.0f, 0.8f), 0, 15, 100); // set shadow properties m_pSceneMgr.ShadowTechnique = ShadowTechnique.SHADOWTYPE_TEXTURE_MODULATIVE; m_pSceneMgr.ShadowColour = new ColourValue(0.5f, 0.5f, 0.5f); m_pSceneMgr.SetShadowTextureSize(1024); m_pSceneMgr.ShadowTextureCount = 1; // disable default camera control so the character can do its own m_pCameraMan.setStyle(CameraStyle.CS_MANUAL); // use a small amount of ambient lighting m_pSceneMgr.AmbientLight = new ColourValue(0.3f, 0.3f, 0.3f); // add a bright light above the scene Light light = m_pSceneMgr.CreateLight(); light.Type = (Light.LightTypes.LT_POINT); light.Position = new Mogre.Vector3(-10, 40, 20); light.SpecularColour = ColourValue.White; // create a floor mesh resource MeshManager.Singleton.CreatePlane("floor", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, new Plane(Mogre.Vector3.UNIT_Y, 0), 100, 100, 10, 10, true, 1, 10, 10, Mogre.Vector3.UNIT_Z); // create a floor entity, give it a material, and place it at the origin SceneProp floorSceneProp = new SceneProp( this, m_pSceneMgr, m_pSceneMgr.RootSceneNode, physicsScene, "Floor", "floor" ); floorSceneProp.SetMaterialName("Examples/Rockwall"); //Navmesh Navmesh floorNavMesh = MeshToNavmesh.LoadNavmesh(floorSceneProp.Entity); NavmeshQuery query; NavmeshPoint retStartPoint; NavmeshPoint retEndPoint; org.critterai.Vector3 pointStart = new org.critterai.Vector3(0, 0, 0); org.critterai.Vector3 pointEnd = new org.critterai.Vector3(0, 0, 0); org.critterai.Vector3 extents = new org.critterai.Vector3(2, 2, 2); NavStatus status = NavmeshQuery.Create(floorNavMesh, 100, out query); Console.WriteLine("Status returned when NavmeshQuery was built: " + status); NavmeshQueryFilter filter = new NavmeshQueryFilter(); filter.IncludeFlags = 1; status = query.GetNearestPoint(pointStart, extents, filter, out retStartPoint); Console.WriteLine("\nStatus of startPoint GetNearestPoint: " + status); status = query.GetNearestPoint(pointEnd, extents, filter, out retEndPoint); Console.WriteLine("\nStatus of endPoint GetNearestPoint: " + status); uint[] path = new uint[100]; int pathCount; status = query.FindPath(retStartPoint, retEndPoint, filter, path, out pathCount); Console.WriteLine("\nStatus of Find path: " + status); // create our character controller m_pChara = new SinbadCharacterController(this, physicsScene, m_pCamera, new Mogre.Vector3(0, 5, 0), 0); SinbadCharacterController bot1 = new SinbadCharacterController(this, physicsScene, m_pCamera, new Mogre.Vector3(-10, 5, 0), 1, false); SinbadCharacterController bot2 = new SinbadCharacterController(this, physicsScene, m_pCamera, new Mogre.Vector3(0, 5, -10), 2, false); SinbadCharacterController bot3 = new SinbadCharacterController(this, physicsScene, m_pCamera, new Mogre.Vector3(10, 5, 0), 3, false); agents.Add(m_pChara); agents.Add(bot1); agents.Add(bot2); agents.Add(bot3); AdvancedMogreFramework.Singleton.m_pTrayMgr.toggleAdvancedFrameStats(); StringVector items = new StringVector(); items.Insert(items.Count, "Help"); ParamsPanel help = AdvancedMogreFramework.Singleton.m_pTrayMgr.createParamsPanel(TrayLocation.TL_TOPLEFT, "HelpMessage", 100, items); help.setParamValue("Help", "H / F1"); }