Inheritance: NativeElement
Esempio n. 1
0
 public Sea(Viewer viewer, SceneNode _parentNode)
     : base(viewer, -1, _parentNode)
 {
     shaderDirectory = Util.ApplicationDataDirectory + @"\media\shaders\";
     modelDirectory = Util.ApplicationDataDirectory + @"\media\models\";
     textureDirectory = Util.ApplicationDataDirectory + @"\media\textures\";
 }
        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);
        }
Esempio n. 3
0
 public DirectionalLight(Viewer viewer, SceneNode _parentNode, string _name)
     : base(viewer, -1)
 {
     parentNode = _parentNode;
     rotation = new Vector3D();
     name = _name;
 }
Esempio n. 4
0
File: Point.cs Progetto: yooyke/work
        public override void Load()
        {
            node = Render.Scene.AddSphereSceneNode(0.1f, 32, Root);
            node.SetMaterialFlag(MaterialFlag.Lighting, true);

            base.Load();
        }
Esempio n. 5
0
 public override void AnimateNode(SceneNode node, uint timeMs)
 {
     Vector3D NewRotation = node.Rotation;
     NewRotation += Rotation* ((timeMs-StartTime)/10.0f);
     node.Rotation = (NewRotation);
     StartTime = timeMs;
 }
Esempio n. 6
0
File: Util.cs Progetto: yooyke/work
        public static Matrix4 AbsoluteMatrix(SceneNode bone)
        {
            Matrix4 mat = bone.RelativeTransformation;

            if (bone.Parent != null)
                mat *= AbsoluteMatrix(bone.Parent);

            return mat;
        }
Esempio n. 7
0
File: Point.cs Progetto: yooyke/work
        public override void Unload()
        {
            if (Root.Children.Length > 0)
                Root.RemoveAll();

            node = null;

            base.Unload();
        }
Esempio n. 8
0
        // Run when the scene is closing
        public override void Cleanup()
        {
            if (parentNode != null)
            {
                Reference.SceneManager.AddToDeletionQueue(parentNode);
                parentNode = null;
            }

            //base.Initialize();
        }
        public LaserDataSceneNode(SceneNode parent, SceneManager mgr, int id)
            : base(parent, mgr, id)
        {
            _mgr = mgr;
            _driver = _mgr.VideoDriver;
            Material.Wireframe = false;
            Material.Lighting = false;

            create_mesh();
        }
        public TextSceneNode AddTextSceneNodeW(GUIFont font, string text, Color color, SceneNode parent)
        {
            IntPtr par = IntPtr.Zero;
            if (parent != null)
                par = parent.Raw;
#if !LINUX
			return (TextSceneNode)
                NativeElement.GetObject(SceneManager_AddTextSceneNodeW(_raw, font.Raw, text, color.ToUnmanaged(), par),
                                        typeof(TextSceneNode));
#else
			return (TextSceneNode)
                NativeElement.GetObject(SceneManager_AddTextSceneNode(_raw, font.Raw, text, color.ToUnmanaged(), par),
                                        typeof(TextSceneNode));
#endif
		}
		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;
		}
Esempio n. 12
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;
        }
Esempio n. 13
0
        public CustomSceneNode(SceneNode parent, SceneManager mgr, int id)
            : base(parent, mgr, id)
        {
            _mgr = mgr;
            _driver = _mgr.VideoDriver;
            Material.Wireframe = false;
            Material.Lighting = false;

            Vertices[0] = new Vertex3D(new Vector3D(0, 0, 10), new Vector3D(1, 1, 0), Color.From(255, 0, 255, 255), new Vector2D(0, 1));
            Vertices[1] = new Vertex3D(new Vector3D(10, 0, -10), new Vector3D(1, 0, 0), Color.From(255, 255, 0, 255), new Vector2D(1, 1));
            Vertices[2] = new Vertex3D(new Vector3D(0, 20, 0), new Vector3D(0, 1, 1), Color.From(255, 255, 255, 0), new Vector2D(1, 0));
            Vertices[3] = new Vertex3D(new Vector3D(-10, 0, -10), new Vector3D(0, 0, 1), Color.From(255, 0, 255, 0), new Vector2D(0, 0));

            Box = new Box3D();
            for (int i = 0; i < Vertices.Length; i++)
                Box.AddInternalPoint(Vertices[i].Position);
        }
        public LensflareSceneNode(SceneNode parent, SceneManager mgr, int id, Vector3D position)
            : base(parent, mgr, id)
        {
            draw_flare = true;
            ign_geom = false;
            smgr = mgr;

            indices = new ushort[6];
            indices[0] = 0;
            indices[1] = 2;
            indices[2] = 1;
            indices[3] = 0;
            indices[4] = 3;
            indices[5] = 2;

            vertices = new Vertex3D[4];
            for (int i = 0; i < 4; i++)
            {
                vertices[i] = new Vertex3D();
            }
            vertices[0].TCoords = Vector2D.From(0.0f, 1.0f);
            vertices[0].Color = Color.White;
            vertices[1].TCoords = Vector2D.From(0.0f, 0.0f);
            vertices[1].Color = Color.White;
            vertices[2].TCoords = Vector2D.From(1.0f, 0.0f);
            vertices[2].Color = Color.White;
            vertices[3].TCoords = Vector2D.From(1.0f, 1.0f);
            vertices[3].Color = Color.White;

            material = new Material();

            material.Lighting = false;

            material.MaterialType = MaterialType.TransparentAddColor;

            material.ZBuffer = 0;

            material.ZWriteEnable = false;

            bbox = new Box3D();

            bbox.MinEdge = Vector3D.From(-2, -2, -2);

            bbox.MaxEdge = Vector3D.From(2, 2, 2);

        }
Esempio n. 15
0
File: Title.cs Progetto: yooyke/work
        public override void Initialize()
        {
            base.Initialize();

            // Set title camera
            System.Type type = this.GetType();
            camera = Render.Scene.AddCameraSceneNode(Render.Scene.RootSceneNode);
            camera.Position = new Vector3D(0, 0, -256);
            camera.Target = new Vector3D(0, 0, 0);
            camera.UpVector = new Vector3D(0, 0, 1);
            camera.Name = type.FullName + ".Camera" ;

            root = Render.Scene.AddEmptySceneNode(Render.Scene.RootSceneNode, -1);
            root.Name = type.FullName + ".Root";

            CreateTitle();
        }
Esempio n. 16
0
        public BeamNode(SceneNode parent, SceneManager mgr, int id, string szBeam)
            : base(parent, mgr, id)
        {
            smgr = mgr;
            driver = smgr.VideoDriver;
            Material = new Material();
            // Setup the beam material
            Material.Wireframe = false;
            Material.Lighting = false;
            Material.MaterialType = MaterialType.TransparentAlphaChannel;
            Material.Texture1 = mgr.VideoDriver.GetTexture(szBeam);

            // Default to 32 units for the scale
            flScale = 32.0f;

            // Default to white
            beamColor.Set(255, 255, 255, 255);
        }
Esempio n. 17
0
 public override void AnimateNode(SceneNode p_node, uint p_currentTimeMs)
 {
     if (m_startTime == 0)
     {
         m_startTime = p_currentTimeMs;
     }
     if (p_currentTimeMs - m_startTime <= m_durationMs)
     {
         Vector3D t_currRotation = p_node.Rotation;
         t_currRotation = m_rotationStart.GetInterpolated(m_rotationEnd, (p_currentTimeMs - m_startTime) / (float)m_durationMs);
         p_node.Rotation = (t_currRotation);
         //m_startTime = p_currentTimeMs;
     }
     else
     {
         p_node.Rotation = m_rotationEnd;
         this.Null();
     }
 }
Esempio n. 18
0
File: Util.cs Progetto: yooyke/work
        public static void CreateBox3DFromNode(SceneNode node, out Box3D box)
        {
            float minX = float.MaxValue;
            float minY = float.MaxValue;
            float minZ = float.MaxValue;
            float maxX = float.MinValue;
            float maxY = float.MinValue;
            float maxZ = float.MinValue;

            Vector3D[] edges;
            node.BoundingBox.GetEdges(out edges);
            Matrix4 m = new Matrix4();
            m.RotationDegrees = node.Rotation;
            m.Translation = node.Position;
            for (int i = 0; i < edges.Length; i++)
            {
                Vector3D v = edges[i] * node.Scale;
                v = m.TransformVect(ref v);

                if (v.X < minX)
                    minX = v.X;

                if (v.Y < minY)
                    minY = v.Y;

                if (v.Z < minZ)
                    minZ = v.Z;

                if (v.X > maxX)
                    maxX = v.X;

                if (v.Y > maxY)
                    maxY = v.Y;

                if (v.Z > maxZ)
                    maxZ = v.Z;
            }

            box = new Box3D(minX, minY, minZ, maxX, maxY, maxZ);
        }
Esempio n. 19
0
        public SceneNode AddGhostSceneNode(SceneNode _parentNode)
        {
            ParticleSystemSceneNode node = Reference.SceneManager.AddParticleSystemSceneNode(false, _parentNode, -1);

            ParticleEmitter em = node.CreateBoxEmitter(
                new Box3D(0, 0, 0, 0.4f, 1.4f, 0.4f),
                new Vector3D(0.000f, 0.0004f, 0.000f),
                20,
                26,
                new Color(0, 255, 255, 191),
                new Color(0, 191, 255, 255),
                600,
                900,
                360
                );

            node.SetEmitter(em);
            em.MinStartSize = new Dimension2Df(0.6f, 0.6f);
            em.MaxStartSize = new Dimension2Df(0.6f, 0.6f);
            em.Drop();
            lock (emitterCleanup) { if (!emitterCleanup.ContainsKey(_parentNode.Raw)) { emitterCleanup.Add(_parentNode.Raw, em); } }

            ParticleAffector paf = node.CreateFadeOutParticleAffector(new Color(0, 0, 0, 0), 150);
            node.AddAffector(paf);
            // paf.Dispose(); <- seems to cause AccessViolationExceptions in AvatarManager
            paf.Drop();
            lock (affectorCleanup) { if (!affectorCleanup.ContainsKey(_parentNode.Raw)) { affectorCleanup.Add(_parentNode.Raw, paf); } }

            node.Position = new Vector3D(0, 0, 0);
            node.SetMaterialFlag(MaterialFlag.Lighting, false);
            node.SetMaterialType(MaterialType.TransparentVertexAlpha);

            Texture tex = Reference.VideoDriver.GetTexture(Util.ApplicationDataDirectory + @"/media/textures/ghost.bmp");
            if (tex != null)
                node.SetMaterialTexture(0, tex);

            return node;
        }
Esempio n. 20
0
        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;
		
        }
Esempio n. 21
0
 public WaterSceneNode(SceneNode parent, SceneManager mgr, Dimension2Df tileSize, Dimension2D tileCount)
     : this(parent, mgr, tileSize, tileCount, new Dimension2D(256, 256), -1)
 {
 }
Esempio n. 22
0
        private int NodeCount(SceneNode node)
        {
            int count = 1;
            foreach (SceneNode child in node.Children)
                count += NodeCount(child);

            return count;
        }
Esempio n. 23
0
        public override void Initialize()
        {
            base.Initialize();

            System.Type type = this.GetType();

            root = Render.Scene.AddEmptySceneNode(Render.Root, id_count++);
            root.Name = type.FullName;
        }
 public TextSceneNode AddBillboardTextSceneNodeW(GUIFont font, string text, SceneNode parent, Dimension2Df size, Vector3D position, int id, Color shade_top, Color shade_down)
 {
     IntPtr par = IntPtr.Zero;
     if (parent != null)
         par = parent.Raw;
     return (TextSceneNode)
         NativeElement.GetObject(SceneManager_AddTextSceneNode2W(_raw, font.Raw, text, par, size.ToUnmanaged(), position.ToUnmanaged(),
                                                         id, shade_top.ToUnmanaged(), shade_down.ToUnmanaged()),
                                 typeof(TextSceneNode));
 }
Esempio n. 25
0
        public void UpdateVoiceEffectSceneNode(SceneNode _parentNode, int _level)
        {
            _level = OpenMetaverse.Utils.Clamp(_level, 0, voiceEffectTexture.Length - 1);

            if (_parentNode is BillboardSceneNode)
                _parentNode.SetMaterialTexture(0, voiceEffectTexture[_level]);
        }
Esempio n. 26
0
 public void RemoveGhostNode(SceneNode _parentNode)
 {
     IntPtr key = _parentNode.Raw;
     if (_parentNode.Children.Length != 0)
     {
         Reference.SceneManager.AddToDeletionQueue(_parentNode.Children[0]);
     }
     lock (emitterCleanup)
     {
         if (emitterCleanup.ContainsKey(key))
         {
             if (NativeElement.Elements.ContainsKey(emitterCleanup[key].Raw))
                 NativeElement.Elements.Remove(emitterCleanup[key].Raw);
             emitterCleanup.Remove(key);
         }
     }
     lock (affectorCleanup)
     {
         if (affectorCleanup.ContainsKey(key))
         {
             if (NativeElement.Elements.ContainsKey(affectorCleanup[key].Raw))
                 NativeElement.Elements.Remove(affectorCleanup[key].Raw);
             affectorCleanup.Remove(key);
         }
     }
 }
Esempio n. 27
0
        public SceneNode AddNameSceneNode(SceneNode _parentNode, string _name, bool _frame)
        {
            SceneNode node = Reference.SceneManager.AddEmptySceneNode(_parentNode, -1);
            node.Position = new Vector3D(0, 1.9f, 0);

            //TextSceneNode textNode = Reference.SceneManager.AddTextSceneNode(Reference.GUIEnvironment.BuiltInFont, _name, Color.White, node);
            TextSceneNode textNode = Reference.SceneManager.AddTextSceneNode(Reference.GUIEnvironment.Skin.Font, _name, Color.White, node);
            //            textNode.Scale = new Vector3D(1.5f, 1.5f, 1);

            // If _frame is true, set font shadow.
            if (_frame)
            {
                //textNode = Reference.SceneManager.AddTextSceneNode(Reference.GUIEnvironment.BuiltInFont, _name, Color.Black, node);
                textNode = Reference.SceneManager.AddTextSceneNode(Reference.GUIEnvironment.Skin.Font, _name, Color.Black, node);
            //                textNode.Scale = new Vector3D(1.6f, 1.6f, 1);
            }

            return node;
        }
Esempio n. 28
0
 public WaterSceneNode(SceneNode parent, SceneManager mgr, Dimension2Df tileSize, Dimension2D tileCount, Dimension2D precision)
     : this(parent, mgr, tileSize, tileCount, precision, -1)
 {
 }
Esempio n. 29
0
 public bool IsUnderwater(SceneNode node)
 {
     return node.AbsolutePosition.Y < AbsolutePosition.Y;
 }
Esempio n. 30
0
        public SceneNode AddVoiceEffectSceneNode(SceneNode _parentNode)
        {
            BillboardSceneNode node = Reference.SceneManager.AddBillboardSceneNode(_parentNode, new Dimension2Df(0.5f, 0.25f), -1);
            node.SetMaterialTexture(0, voiceEffectTexture[0]);
            node.Position = new Vector3D(0, 2.2f, 0);
            node.SetMaterialType(MaterialType.TransparentAlphaChannel);
            node.SetMaterialFlag(MaterialFlag.Lighting, false);
            node.Visible = false;

            return node;
        }