Наследование: NativeElement
        public GrassPatchSceneNode(SceneNode parent, SceneManager mgr, int id, bool createIfEmpty,
                                   Vector3D gridPos, string filepath, Texture heightMap, Texture colourMap,
                                   Texture grassMap, SceneNode terrain, WindGenerator wind)
            : base(parent, mgr, id)
        {
            DrawDistance = GRASS_PATCH_SIZE * 1.5f;
            MaxDensity = 800;
            TerrainHeightMap = heightMap;
            TerrainColourMap = colourMap;
            TerrainGrassMap = grassMap;
            Terrain = terrain;
            WindGen = wind;
            lastwindtime = 0;
            lastdrawcount = 0;
            redrawnextloop = true;
            MaxFPS = 0;
            _mgr = mgr;
            WindRes = 5;

            filename = string.Format("{0}/{1}.{2}.grass", filepath, gridpos.X, gridpos.Z);
            gridpos = gridPos;
            Position = new Vector3D(gridpos.X * GRASS_PATCH_SIZE, 0f,
                                    gridpos.Z * GRASS_PATCH_SIZE);

            ImageCount = new Dimension2D(4, 2);

            if (!Load())
                Create(createIfEmpty);
        }
Пример #2
0
 public void SafeCopyInto(Texture tex)
 {
     Color[,] col = Retrieve();
     ModifyPixel del = delegate(int x, int y, out Color result)
     {
         result = col[x, y];
         return true;
     };
     tex.Modify(del);
 }
Пример #3
0
        public override void Initialize()
        {
            base.Initialize();

            tex = Render.RenderData.BlankTexture;
            fade_tex = tex;
            rect = new Rect(0, 0, Ox.DataStore.Width, Ox.DataStore.Height);
            Ox.IO.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(IO_DownloadFileCompleted);

            CreateTimer();
        }
Пример #4
0
        public ATMOSkySceneNode(Texture tex, SceneNode parent, SceneManager mgr, int faces, int id)
            : base(parent, mgr, id)
        {
            smgr = mgr;
            AutomaticCulling = CullingType.Off;
            material = new Material();
            material.Lighting = false;
            material.ZBuffer = 0;
            material.Texture1 = tex;

            face = faces;
            vertices = new Vertex3D[face + 1];
            indices = new ushort[face * 3];

            double angle = 0.0f;
            double angle2 = 360.0f / face;
            vert = 0;                          //vertice nr
            int nr = -3;                     //indices nr

            vertices[0] = new Vertex3D(Vector3D.From(0.0f, 100.0f, 0.0f),
                                       Vector3D.From(0.0568988f, 0.688538f, -0.722965f),
                                       Color.White,
                                       Vector2D.From(0.0f, 0.1f)
                                      );

            double x, z;

            for (ushort n = 1; n < face + 1; n++)
            {
                vert++;
                nr += 3;
                x = Math.Cos(angle * 0.017453292519943295769236907684886f) * 100;
                z = Math.Sin(angle * 0.017453292519943295769236907684886f) * 100;

                vertices[vert] = new Vertex3D(Vector3D.From((float)x, -5.0f, (float)z),
                                       Vector3D.From(0.0568988f, 0.688538f, -0.722965f),
                                       Color.White,
                                       Vector2D.From(0.0f, 0.9f)
                                      );

                angle = angle + angle2;
                indices[nr] = 0;
                indices[nr + 1] = (ushort)vert;
                indices[nr + 2] = (ushort)(vert + 1);
            }
            indices[nr + 2] = 1;
        }
Пример #5
0
		public WaterSceneNode(SceneNode parent, SceneManager mgr, Dimension2Df tileSize,
		                      Dimension2D tileCount, Dimension2D precision, int id) : 
			base(parent, mgr, id)
		{
			_scene = mgr;
			_driver = mgr.VideoDriver;
			
			AnimatedMesh wmesh =  _scene.AddHillPlaneMesh("watermesh" + _current,
                tileSize,
                tileCount, 0,
                new Dimension2Df(0, 0),
                new Dimension2Df(1, 1));
           	_current++; 
           	 
            int dmat = (int)MaterialType.Reflection2Layer;
            if(_driver.DriverType == DriverType.OpenGL)
                dmat = _driver.GPUProgrammingServices.AddHighLevelShaderMaterial(
                 WATER_VERTEX_GLSL, "main", VertexShaderType._1_1, WATER_FRAGMENT_GLSL,
                 "main", PixelShaderType._1_1, OnShaderSet, MaterialType.TransparentAlphaChannel, 0);
            else
                dmat = _driver.GPUProgrammingServices.AddHighLevelShaderMaterial(
                 WATER_HLSL, "vertexMain", VertexShaderType._2_0, WATER_HLSL,
                 "pixelMain", PixelShaderType._2_0, OnShaderSet, MaterialType.TransparentAlphaChannel, 2);

            if (_driver.DriverType == DriverType.OpenGL)
                ClampShader = _driver.GPUProgrammingServices.AddHighLevelShaderMaterial(
                 CLAMP_VERTEX_GLSL, "main", VertexShaderType._1_1, CLAMP_FRAGMENT_GLSL,
                 "main", PixelShaderType._1_1, OnShaderSet, MaterialType.TransparentAlphaChannel, 1);
            else
                ClampShader = _driver.GPUProgrammingServices.AddHighLevelShaderMaterial(
                 CLAMP_HLSL, "vertexMain", VertexShaderType._2_0, CLAMP_HLSL,
                 "pixelMain", PixelShaderType._2_0, OnShaderSet, MaterialType.TransparentAlphaChannel, 3);
                 
           	_waternode = _scene.AddMeshSceneNode(wmesh.GetMesh(0), this, -1);  
            _waternode.SetMaterialType(dmat);
            _waternode.SetMaterialFlag(MaterialFlag.BackFaceCulling, false);
            _waternode.SetMaterialFlag(MaterialFlag.Lighting, false);
            _waternode.SetMaterialFlag(MaterialFlag.FogEnable, false);
            
            _rt = _driver.CreateRenderTargetTexture(precision);
            _waternode.SetMaterialTexture(0, _rt); 
            
            CameraSceneNode oldcam = _scene.ActiveCamera;
            _fixedcam = _scene.AddCameraSceneNode(null);
            if(oldcam != null)
            	_scene.ActiveCamera = oldcam;
		}
Пример #6
0
 public void Draw2DImage(Texture image, Position2D destPos, Color color, bool useAlphaChannel)
 {
     Draw2DImage(image, destPos, new Rect(new Position2D(0, 0), image.OriginalSize), color, useAlphaChannel);
 }
Пример #7
0
 public void Draw2DImage(Texture image, Position2D destPos)
 {
     VideoDriver_Draw2DImageA(_raw, image.Raw, destPos.ToUnmanaged());
 }
Пример #8
0
 public void Draw2DImage(Texture image, Rect destRect, Rect sourceRect, Rect clipRect, Color color, bool useAlpha)
 {
     VideoDriver_Draw2DImageC(_raw, image.Raw, destRect.ToUnmanaged(), sourceRect.ToUnmanaged(), clipRect.ToUnmanaged(), color.ToUnmanaged(), color.ToUnmanaged(), color.ToUnmanaged(), color.ToUnmanaged(), useAlpha);
 }
Пример #9
0
        /// <summary>
        /// Applies individual face settings
        /// </summary>
        /// <param name="vObj"></param>
        /// <param name="alpha">Is this an alpha texture</param>
        /// <param name="teface">Texture Entry Face</param>
        /// <param name="tex">Texture to apply</param>
        /// <param name="face">Which face this is</param>
        /// <param name="shinyval">The selected shiny value</param>
        /// <param name="coldata">The modified Color settings</param>
        public void ApplyFaceSettings(VObject vObj, bool alpha, Primitive.TextureEntryFace teface, Texture tex, int face, 
            float shinyval, Color4 coldata)
        {
            // Apply texture
            if (tex != null)
            {
                vObj.Mesh.GetMeshBuffer(face).Material.Texture1 = tex;
            }

            // Apply colors/transforms
            if (teface != null)
            {
                ApplyFace(vObj, alpha, face, teface, shinyval, coldata);
            }
        }
Пример #10
0
 /// <summary>
 /// Adds a simple skybox. A skybox is a basic cube rendered before everything and used to simulate an external environment with only textures.
 /// </summary>
 /// <returns>The skybox scene node (it should NOT be used since the skybox may not be moved nor rotated)</returns>
 /// <param name="parent">Its parent (should be set to null)</param>
 /// <param name="textureList">List of 6 Textures that constitute the skybox, order : top, bottom, left, right, front, back</param>
 /// <param name="id">ID of the node, -1 for automatic assign.</param>
 public SceneNode AddSkyBoxSceneNode(SceneNode parent, Texture[] textureList, int id)
 {
     IntPtr par = IntPtr.Zero;
     if(parent != null)
         par = parent.Raw;
     IntPtr top, bottom, left, right, front, back;
     top = textureList[0].Raw;
     bottom = textureList[1].Raw;
     right = textureList[2].Raw;
     left = textureList[3].Raw;
     front = textureList[4].Raw;
     back = textureList[5].Raw;
     return (SceneNode)
         NativeElement.GetObject(SceneManager_AddSkyBoxSceneNode(_raw, top, bottom, left, right, front, back, par, id),
                                 typeof(SceneNode));
 }
Пример #11
0
 public void RemoveTexture(Texture text)
 {
     VideoDriver_RemoveTexture(_raw, text.Raw);
 }
Пример #12
0
 /// <summary>
 /// Creates an 1bit alpha channel of the texture based on a color
 /// </summary>
 /// <param name="texture">Input texture that will be modified</param>
 /// <param name="color">Color</param>
 public void MakeColorKeyTexture(Texture texture, Color color)
 {
     VideoDriver_MakeColorKeyTextureA(_raw, texture.Raw, color.ToUnmanaged());
 }
Пример #13
0
        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;
        }
Пример #14
0
 public GUIButton AddButton(int id, string text, string tooltip, Texture img, Texture pressedimg, bool isPushButton, bool useAlphaChannel)
 {
     return (GUIButton)NativeElement.GetObject(
         GUIToolBar_AddButton(_raw, id, text, tooltip, img == null ? IntPtr.Zero : img.Raw, pressedimg == null ? IntPtr.Zero : pressedimg.Raw, isPushButton, useAlphaChannel),
         typeof(GUIButton));
 }
Пример #15
0
 public void SetPressedImage(Texture image)
 {
     GUIButton_SetPressedImageA(_raw, image.Raw);
 }
Пример #16
0
 public void SetPressedImage(Texture image, Rect pos)
 {
     GUIButton_SetPressedImage(_raw, image.Raw, pos.ToUnmanaged());
 }
Пример #17
0
 public GUIImage AddImage(Texture image, Position2D position, bool useAlphaChannel, GUIElement parent, int id, string text)
 {
     IntPtr par = (parent == null ? IntPtr.Zero : parent.Raw);
     return (GUIImage)NativeElement.GetObject(GuiEnv_AddImageA(_raw, image.Raw, position.ToUnmanaged(), useAlphaChannel, par, id, text),
                                               typeof(GUIImage));
 }
Пример #18
0
 void fade_OnHalf(object sender, EventArgs e)
 {
     tex = list[index];
     index = ((index + 1) % list.Count);
 }
Пример #19
0
        private void Change(object state)
        {
            if (list.Count == 0)
                return;

            fade_tex = tex;
            fade = new OxUtil.Fade(16);
            fade.OnHalf += new EventHandler(fade_OnHalf);
            fade.OnEnd += new EventHandler(fade_OnEnd);
        }
Пример #20
0
 public void Draw2DImage(Texture image, Position2D destPos, bool useAlphaChannel)
 {
     Draw2DImage(image, destPos, Color.White, useAlphaChannel);
 }
Пример #21
0
 /// <summary>
 /// Creates an 1bit alpha channel of the texture based on a pixel position color
 /// </summary>
 /// <param name="texture">Input texture that will be modified</param>
 /// <param name="colorKeyPixelPos">Position of the pixel with the color key</param>
 public void MakeColorKeyTexture(Texture texture, Position2D colorKeyPixelPos)
 {
     VideoDriver_MakeColorKeyTexture(_raw, texture.Raw, colorKeyPixelPos.ToUnmanaged());
 }
Пример #22
0
 public void SetMaterialTexture(int layer, Texture text)
 {
     SceneNode_SetMaterialTexture(_raw, layer, (text == null ? IntPtr.Zero : text.Raw));
 }
Пример #23
0
 /// <summary>
 /// Creates a normal map from heightmap texture
 /// </summary>
 /// <param name="texture">Input texture that will be modified</param>
 /// <param name="amplitude">Constant value which by the height information is multiplied</param>
 public void MakeNormalMapTexture(Texture texture, float amplitude)
 {
     VideoDriver_MakeNormalMapTexture(_raw, texture.Raw, amplitude);
 }
Пример #24
0
 public SceneNode AddTreeSceneNode(string XMLString, SceneNode parent, int id, Vector3D position,
     Vector3D rotation, Vector3D scale, Texture TreeTexture, Texture LeafTexture, Texture BillTexture)
 {
     IntPtr par = IntPtr.Zero;
     if (parent != null)
         par = parent.Raw;
     return (SceneNode)
         NativeElement.GetObject(SceneManager_AddTreeSceneNode(_raw, XMLString, par, id, position.ToUnmanaged(), rotation.ToUnmanaged(), scale.ToUnmanaged(), TreeTexture.Raw, LeafTexture.Raw, BillTexture.Raw, (int)MaterialType.TransparentAlphaChannel), typeof(SceneNode));
 }
Пример #25
0
 public void SetRenderTarget(Texture target, bool clearBackBuffer, bool clearZBuffer, Color color)
 {
     VideoDriver_SetRenderTarget(_raw, (target == null ? IntPtr.Zero : target.Raw), clearBackBuffer, clearZBuffer, color.ToUnmanaged());
 }
Пример #26
0
 public void Draw2DImage(Texture image, Rect destRect, Rect sourceRect, Color[] color, bool useAlpha)
 {
     VideoDriver_Draw2DImageD(_raw, image.Raw, destRect.ToUnmanaged(), sourceRect.ToUnmanaged(), color[0].ToUnmanaged(), color[1].ToUnmanaged(), color[2].ToUnmanaged(), color[3].ToUnmanaged(), useAlpha);
 }
Пример #27
0
 /// <summary>
 /// Adds a skydome scene node to the scene graph. 
 /// A skydome is a large (half-) sphere with a panoramic texture on the inside and is drawn around the camera position. 
 /// </summary>
 /// <param name="texture">Texture for the dome. </param>
 /// <param name="horiRes">Number of vertices of a horizontal layer of the sphere. </param>
 /// <param name="vertRes">Number of vertices of a vertical layer of the sphere. </param>
 /// <param name="texturePercentage">How much of the height of the texture is used. Should be between 0 and 1. </param>
 /// <param name="spherePercentage">How much of the sphere is drawn. Value should be between 0 and 2, where 1 is an exact half-sphere and 2 is a full sphere. </param>
 /// <param name="parent">Parent scene node of the dome. A dome usually has no parent, so this should be null. Note: If a parent is set, the dome will not change how it is drawn.</param>
 /// <returns>The scene node</returns>
 public SceneNode AddSkyDomeSceneNode(Texture texture, uint horiRes, uint vertRes, double texturePercentage, double spherePercentage, SceneNode parent)
 {
     IntPtr par = IntPtr.Zero;
     if(parent != null)
         par = parent.Raw;
     return (SceneNode)
         NativeElement.GetObject(SceneManager_AddSkyDomeSceneNode(_raw, texture.Raw, horiRes, vertRes, texturePercentage, spherePercentage, par),
                                 typeof(SceneNode));
 }
Пример #28
0
 public SceneNode CreateLensflare(Texture tex)
 {
     lens = new LensflareSceneNode(sun, smgr, -1, new Vector3D(0, 0, 0));
     lens.Material.Texture1 = tex;
     return lens;
 }
Пример #29
0
 /// <summary>
 /// Creates an animator that will switch every [timePerFrame] miliseconds the textures of the node.
 /// </summary>
 /// <param name="textures">List of textures</param>
 /// <param name="timePerFrame">Time (miliseconds) between each switch</param>
 /// <param name="loop">Does the animation loop ?</param>
 /// <returns>An animator to be added with SceneNode.AddAnimator</returns>
 public Animator CreateTextureAnimator(Texture[] textures, int timePerFrame, bool loop)
 {
     IntPtr[] array = new IntPtr[textures.Length];
     for(int i = 0; i < textures.Length; i++)
         array[i] = textures[i].Raw;
     return (Animator)
         NativeElement.GetObject(SceneManager_CreateTextureAnimator(_raw, array, array.Length, timePerFrame, loop),
                                 typeof(Animator));
 }
Пример #30
0
 public void Draw2DImage(Texture image, Position2D destPos, Rect sourceRect, Color color, bool useAlpha)
 {
     VideoDriver_Draw2DImageB(_raw, image.Raw, destPos.ToUnmanaged(), sourceRect.ToUnmanaged(), color.ToUnmanaged(), useAlpha);
 }