/// <summary> /// Tworzy gotow¹ powierzchniê wody. /// </summary> /// <param name="cfgFileName"></param> /// <param name="sceneMgr"></param> /// <param name="camera"></param> /// <param name="viewport"></param> public void CreateHydrax(string cfgFileName, SceneManager sceneMgr, Camera camera, Viewport viewport) { if (hydrax != null) { hydrax.Dispose(); hydrax = null; } if (USE_UPDATER_THREAD) { stopUpdater = false; updater = new Thread(UpdateLoop); } hydrax = new MHydrax.MHydrax(sceneMgr, camera, viewport); MProjectedGrid module = new MProjectedGrid( // Hydrax parent pointer hydrax, // Noise module new MHydrax.MPerlin(), // Base plane new Mogre.Plane(new Vector3(0, 1, 0), new Vector3(0, 0, 0)), // Normal mode MMaterialManager.MNormalMode.NM_VERTEX, // Projected grid options new MProjectedGrid.MOptions(32, 10, 5, false, false, true, 3.75f)); this.cfgFileName = cfgFileName; hydrax.SetModule(module); if (hydrax.LoadCfg(cfgFileName)) { // Console.WriteLine("OKOKOK"); } hydrax.Create(); // MaterialPtr m = hydrax.MaterialManager.GetMaterial(MMaterialManager.MMaterialType.MAT_UNDERWATER_COMPOSITOR); // m.GetBestTechnique().GetPass(0).GetTextureUnitState(1).SetTextureName("UnderwaterDistortion_none.png"); // m = null; // hydrax.MaterialManager.RemoveCompositor(); // CompositorPtr com = hydrax.MaterialManager.GetCompositor(MHydrax.MMaterialManager.MCompositorType.COMP_UNDERWATER); // com.RemoveAllTechniques(); }
public void ReCreateHydrax(SceneManager sceneMgr, Camera camera, Viewport viewport) { // RemoveHydraxDepthTechniques(); MProjectedGrid module = new MProjectedGrid( // Hydrax parent pointer hydrax, // Noise module new MHydrax.MPerlin(), // Base plane new Mogre.Plane(new Vector3(0, 1, 0), new Vector3(0, 0, 0)), // Normal mode MMaterialManager.MNormalMode.NM_VERTEX, // Projected grid options new MProjectedGrid.MOptions(32, 10, 5, false, false, true, 3.75f)); hydrax.SetModule(module); if (hydrax.LoadCfg(cfgFileName)) { // Console.WriteLine("OKOKOK"); } AddHydraxDepthTechniques(); }
protected static void CreateScene() { sceneMgr = _root.CreateSceneManager(SceneType.ST_EXTERIOR_CLOSE); //Image combined = new Image(); //combined.LoadTwoImagesAsRGBA("terra_DIFFUSE.png", "terra_SPECULAR.png", "General", PixelFormat.PF_BYTE_RGBA); //combined.Save("terra_diffusespecular.png"); //combined.LoadTwoImagesAsRGBA("terra_NORMAL.png", "terra_DISP.png", "General", PixelFormat.PF_BYTE_RGBA); //combined.Save("terra_normalheight.png"); _cam = sceneMgr.CreateCamera("Camera"); _cam.Pitch(-0.78f); _cam.NearClipDistance = 5f; _cam.FarClipDistance = 99999 * 6; _cam.Move(new Vector3(1084, 346, 1317)); viewport = _window.AddViewport(_cam); _cam.AspectRatio = (float)viewport.ActualWidth / (float)viewport.ActualHeight; sceneMgr.ShadowTechnique = ShadowTechnique.SHADOWTYPE_TEXTURE_MODULATIVE; sceneMgr.ShadowTextureCount = 8; sceneMgr.SetShadowTextureSize(8192); CreateNewDude("1"); CreateNewDude("2"); Vector3 lightDir = new Vector3(0.55f, -0.3f, 0.75f); lightDir.Normalise(); Light light = sceneMgr.CreateLight("tstLight"); light.Type = Light.LightTypes.LT_DIRECTIONAL; light.Direction = lightDir; light.DiffuseColour = ColourValue.White; light.SpecularColour = ColourValue.White; light.CastShadows = false; light.Visible = true; sceneMgr.AmbientLight = ColourValue.White; tgo = new TerrainGlobalOptions(); tg = new TerrainGroup(sceneMgr, Terrain.Alignment.ALIGN_X_Z, 513, 12000.0f); tg.SetFilenameConvention("Asd", "dat"); tg.Origin = new Vector3(0, -250, 0); ConfigureTerrainDefaults(light); for (int x = 0; x <= 0; ++x) { for (int y = 0; y <= 0; ++y) { DefineTerrain(x, y); } } tg.LoadAllTerrains(true); if (mTerrainImported) { foreach (TerrainGroup.TerrainSlot t in tg.GetTerrainIterator()) { InitBlendMaps(t.instance); } } tg.FreeTemporaryResources(); // tg.SaveAllTerrains(true); hydrax = new MHydrax.MHydrax(sceneMgr, _cam, viewport); hydrax.Components = MHydraxComponent.HYDRAX_COMPONENTS_ALL; Plane p = new Plane(new Vector3(0, 1, 0), new Vector3(0, 0, 0)); MHydrax.MProjectedGrid m = new MProjectedGrid(hydrax, new MPerlin(new MPerlin.MOptions(8, 0.085f, 0.49f, 1.4f, 1.27f, 2, new Vector3(0.5f, 50, 150000))), p, MMaterialManager.MNormalMode.NM_VERTEX, new MHydrax.MProjectedGrid.MOptions(56, 35, 50, false, false, false, 3.75f)); hydrax.SetModule(m); hydrax.CfgFileManager.Load("TestiPeli.hdx"); hydrax.Create(); // sceneMgr.SetSkyDome(true, "Examples/CloudySky", 5, 8); mRect = new SelectionRectangle("Selection SelectionRectangle"); sceneMgr.RootSceneNode.CreateChildSceneNode("debug_object").AttachObject(mRect); mRect._camera = _cam; ct = new CollisionTools(sceneMgr); SetupCaelum(viewport, _window); }