public ATMOSphere(Timer _timer, SceneNode parent, SceneManager mgr, int id) : base(parent, mgr, id) { smgr = mgr; driver = smgr.VideoDriver; timer = _timer; currentTime = timer.RealTime; startTime = timer.RealTime; dTime = 0.0f; rad = 0.017453292519943295769236907684886f; sun_angle = new double[2]; Ndate = new ushort[5]; J1minute = 1.0f / 1440.0f; sun_interpolation_speed = 30.0f; dayspeed = 60.0f; vieta = new double[4]; J = DateToJulian(2006, 2, 27, 7, 50); J1 = J; counter_time = 0.0f; uvX = 0.0f; time_int_step = 0.0f; }
public override int Load() { if (WaterSceneNode == null) { const string filename = "advanced_sea_shader.fx"; Timer = Reference.Device.Timer; Size = new Dimension2Df(256, 256); if (Reference.SceneManager.ActiveCamera != null) { CameraSceneNode currentCamera = Reference.SceneManager.ActiveCamera; Camera = Reference.SceneManager.AddCameraSceneNode(parentNode); Camera.FarValue = currentCamera.FarValue; Camera.FOV = currentCamera.FOV; Reference.SceneManager.ActiveCamera = currentCamera; } else { Camera = Reference.SceneManager.AddCameraSceneNode(parentNode); } AnimatedMesh mesh = Reference.SceneManager.AddHillPlaneMesh("terrain", new Dimension2Df(512, 512), new Dimension2D(256, 256), 0.0f, new Dimension2Df(0, 0), new Dimension2Df(1024, 1024)); SceneNode amsn = Reference.SceneManager.AddOctTreeSceneNode(mesh, parentNode, -1, 128); amsn.Position = new Vector3D(128, 0, 128); amsn.SetMaterialTexture(0, Reference.VideoDriver.GetTexture(Util.ApplicationDataDirectory + @"\media\textures\sand01.jpg")); AnimatedMesh watermesh = Reference.SceneManager.AddHillPlaneMesh("realisticwater", Size, new Dimension2D(1, 1), 0f, new Dimension2Df(0, 0), new Dimension2Df(1, 1)); WaterSceneNode = Reference.SceneManager.AddOctTreeSceneNode(watermesh, parentNode, -1, 128); Texture bumpTexture = Reference.VideoDriver.GetTexture(Util.ApplicationDataDirectory + @"\media\textures\waterbump.jpg"); GPUProgrammingServices gpuProgrammingServices = Reference.VideoDriver.GPUProgrammingServices; string path = Util.ApplicationDataDirectory + @"\media\shaders\" + filename; if (System.IO.File.Exists(path)) { try { ShaderMaterial = Reference.VideoDriver.GPUProgrammingServices.AddHighLevelShaderMaterialFromFiles( path, "VertexShaderFunction", VertexShaderType._2_0, path, "PixelShaderFunction", PixelShaderType._2_0, ShaderEvent, MaterialType.Lightmap, 0 ); } catch (Exception e) { Reference.Log.Fatal("Load", e); } if (ShaderMaterial > 0) Reference.Log.Debug("Load: Loaded" + path); else Reference.Log.Debug("Load: not Loaded:" + path); } else { Viewer.Log.Warn("[SHADER] [SEA] Shader file was not found: " + Util.ApplicationDataDirectory + @"\media\shaders\" + filename); } float waterheight = 0; if (Reference.Viewer.ProtocolManager.AvatarConnection.m_user.Network.CurrentSim != null) { waterheight = Reference.Viewer.ProtocolManager.AvatarConnection.m_user.Network.CurrentSim.WaterHeight; } WaterSceneNode.Position = new Vector3D(128, waterheight, 128); WaterSceneNode.Scale = new Vector3D(200, 1, 200); WaterSceneNode.SetMaterialType(ShaderMaterial); WaterSceneNode.SetMaterialTexture(0, bumpTexture); RefractionMap = Reference.VideoDriver.CreateRenderTargetTexture(renderTargetSize); ReflectionMap = Reference.VideoDriver.CreateRenderTargetTexture(renderTargetSize); WaterSceneNode.SetMaterialTexture(1, RefractionMap); WaterSceneNode.SetMaterialTexture(2, ReflectionMap); } return ShaderMaterial; }