Ejemplo n.º 1
0
        public override void Draw(GraphicsDevice device, ThreeDScene scene)
        {
            for(int i = 0; i < m_Effects.Count; i++)
            {
                for(int j = 0; j < m_CurrentSims.Count; j++)
                {
                //    if (m_CurrentSims[j].HeadTexture != null)
                //    {
                //        m_Effects[i].World = m_Scene.SceneMgr.WorldMatrix *
                //            Matrix.CreateTranslation(new Vector3(m_CurrentSims[j].HeadXPos, m_CurrentSims[j].HeadYPos, 0.0f));
                //        m_Effects[i].View = Matrix.CreateLookAt(Vector3.Backward * 17, Vector3.Zero, Vector3.Right);
                //        m_Effects[i].Projection = m_Scene.SceneMgr.ProjectionMatrix;

                //        m_Effects[i].Texture = m_CurrentSims[j].HeadTexture;
                //        m_Effects[i].TextureEnabled = true;

                //        m_Effects[i].EnableDefaultLighting();

                //        m_Effects[i].CommitChanges();

                //        // Draw
                //        m_Effects[i].Begin();

                //        for(int k = 0; k < m_Effects[i].Techniques.Count; k++)
                //        {
                //            foreach (EffectPass Pass in m_Effects[i].Techniques[k].Passes)
                //            {
                //                Pass.Begin();

                //                foreach (Sim Character in m_CurrentSims)
                //                {
                //                    foreach (Face Fce in Character.HeadMesh.FaceData)
                //                    {
                //                        if (Character.HeadMesh.VertexTexNormalPositions != null)
                //                        {
                //                            VertexPositionNormalTexture[] Vertex = new VertexPositionNormalTexture[3];
                //                            Vertex[0] = Character.HeadMesh.VertexTexNormalPositions[Fce.VertexA];
                //                            Vertex[1] = Character.HeadMesh.VertexTexNormalPositions[Fce.VertexB];
                //                            Vertex[2] = Character.HeadMesh.VertexTexNormalPositions[Fce.VertexC];

                //                            Vertex[0].TextureCoordinate = Character.HeadMesh.VertexTexNormalPositions[Fce.VertexA].TextureCoordinate;
                //                            Vertex[1].TextureCoordinate = Character.HeadMesh.VertexTexNormalPositions[Fce.VertexB].TextureCoordinate;
                //                            Vertex[2].TextureCoordinate = Character.HeadMesh.VertexTexNormalPositions[Fce.VertexC].TextureCoordinate;

                //                            m_Scene.SceneMgr.Device.DrawUserPrimitives<VertexPositionNormalTexture>(
                //                                PrimitiveType.TriangleList, Vertex, 0, 1);
                //                        }
                //                    }
                //                }

                //                Pass.End();
                //                m_Effects[i].End();
                //            }
                //        }
                //    }
                }
            }
        }
Ejemplo n.º 2
0
        public override void Draw(GraphicsDevice device, ThreeDScene scene)
        {
            for (int i = 0; i < m_Effects.Count; i++)
            {
                for (int j = 0; j < m_CurrentSims.Count; j++)
                {
                    if (m_CurrentSims[j].HeadTexture != null)
                    {
                        m_Effects[i].World = m_Scene.SceneMgr.WorldMatrix *
                                             Matrix.CreateTranslation(new Vector3(m_CurrentSims[j].HeadXPos, m_CurrentSims[j].HeadYPos, 0.0f));
                        m_Effects[i].View       = Matrix.CreateLookAt(Vector3.Backward * 17, Vector3.Zero, Vector3.Right);
                        m_Effects[i].Projection = m_Scene.SceneMgr.ProjectionMatrix;

                        m_Effects[i].Texture        = m_CurrentSims[j].HeadTexture;
                        m_Effects[i].TextureEnabled = true;

                        m_Effects[i].EnableDefaultLighting();

                        m_Effects[i].CommitChanges();

                        // Draw
                        m_Effects[i].Begin();

                        for (int k = 0; k < m_Effects[i].Techniques.Count; k++)
                        {
                            foreach (EffectPass Pass in m_Effects[i].Techniques[k].Passes)
                            {
                                Pass.Begin();

                                foreach (Sim Character in m_CurrentSims)
                                {
                                    foreach (Face Fce in Character.HeadMesh.FaceData)
                                    {
                                        if (Character.HeadMesh.VertexTexNormalPositions != null)
                                        {
                                            VertexPositionNormalTexture[] Vertex = new VertexPositionNormalTexture[3];
                                            Vertex[0] = Character.HeadMesh.VertexTexNormalPositions[Fce.VertexA];
                                            Vertex[1] = Character.HeadMesh.VertexTexNormalPositions[Fce.VertexB];
                                            Vertex[2] = Character.HeadMesh.VertexTexNormalPositions[Fce.VertexC];

                                            Vertex[0].TextureCoordinate = Character.HeadMesh.VertexTexNormalPositions[Fce.VertexA].TextureCoordinate;
                                            Vertex[1].TextureCoordinate = Character.HeadMesh.VertexTexNormalPositions[Fce.VertexB].TextureCoordinate;
                                            Vertex[2].TextureCoordinate = Character.HeadMesh.VertexTexNormalPositions[Fce.VertexC].TextureCoordinate;

                                            m_Scene.SceneMgr.Device.DrawUserPrimitives <VertexPositionNormalTexture>(
                                                PrimitiveType.TriangleList, Vertex, 0, 1);
                                        }
                                    }
                                }

                                Pass.End();
                                m_Effects[i].End();
                            }
                        }
                    }
                }
            }
        }
        public override void Draw(GraphicsDevice device, ThreeDScene scene)
        {
            if (m_Sim == null) { return; }

            device.VertexDeclaration = new VertexDeclaration(device, VertexPositionNormalTexture.VertexElements);

            var world = World;

            foreach (var effect in m_Effects)
            {
                effect.World = world;

                effect.View = scene.Camera.View;
                effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.Pi / 4.0f,
                    (float)device.PresentationParameters.BackBufferWidth /
                    (float)device.PresentationParameters.BackBufferHeight,
                    1.0f, 100.0f);

                effect.Projection = scene.Camera.Projection;

                effect.Texture = m_Sim.HeadTexture;
                effect.TextureEnabled = true;
                effect.CommitChanges();
                effect.Begin();

                foreach (var pass in effect.CurrentTechnique.Passes)
                {
                    pass.Begin();

                    foreach (Face Fce in m_Sim.HeadMesh.FaceData)
                    {
                        if (m_Sim.HeadMesh.VertexTexNormalPositions != null)
                        {
                            VertexPositionNormalTexture[] Vertex = new VertexPositionNormalTexture[3];
                            Vertex[0] = m_Sim.HeadMesh.VertexTexNormalPositions[Fce.VertexA];
                            Vertex[1] = m_Sim.HeadMesh.VertexTexNormalPositions[Fce.VertexB];
                            Vertex[2] = m_Sim.HeadMesh.VertexTexNormalPositions[Fce.VertexC];

                            Vertex[0].TextureCoordinate = m_Sim.HeadMesh.VertexTexNormalPositions[Fce.VertexA].TextureCoordinate;
                            Vertex[1].TextureCoordinate = m_Sim.HeadMesh.VertexTexNormalPositions[Fce.VertexB].TextureCoordinate;
                            Vertex[2].TextureCoordinate = m_Sim.HeadMesh.VertexTexNormalPositions[Fce.VertexC].TextureCoordinate;

                            GameFacade.GraphicsDevice.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, Vertex, 0, 1);
                        }
                    }

                    pass.End();
                }

                effect.End();
            }
        }
        private List<TreeNode> ExploreScene(ThreeDScene container)
        {
            var result = new List<TreeNode>();

            foreach (var child in container.GetElements())
            {
                var node = new TreeNode(child.ToString());
                ItemMap.Add(node, child);
                result.Add(node);
            }

            return result;
        }
Ejemplo n.º 5
0
        public override void Draw(GraphicsDevice device, ThreeDScene scene)
        {
            if (m_Sim == null) { return; }

            device.VertexDeclaration = new VertexDeclaration(device, VertexPositionNormalTexture.VertexElements);
            device.RenderState.CullMode = CullMode.None;

            var world = World;

            foreach (var effect in m_Effects)
            {
                effect.World = world;
                effect.View = scene.Camera.View;
                effect.Projection = scene.Camera.Projection;

                /** Head **/
                foreach (var binding in m_Sim.HeadBindings)
                {
                    effect.Texture = binding.Texture;
                    effect.TextureEnabled = true;
                    effect.CommitChanges();
                    effect.Begin();

                    foreach (var pass in effect.CurrentTechnique.Passes)
                    {
                        pass.Begin();
                        binding.Mesh.Draw(device);
                        pass.End();
                    }

                    effect.End();
                }

                foreach (var binding in m_Sim.BodyBindings)
                {
                    effect.Texture = binding.Texture;
                    effect.TextureEnabled = true;
                    effect.CommitChanges();
                    effect.Begin();

                    foreach (var pass in effect.CurrentTechnique.Passes)
                    {
                        pass.Begin();
                        binding.Mesh.Draw(device);
                        pass.End();
                    }

                    effect.End();
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Constructs a new UI3DView instance. 
        /// </summary>
        /// <param name="Width">The width of this UI3DView surface.</param>
        /// <param name="Height">The height of this UI3DView surface.</param>
        /// <param name="SingleRenderer">Will this surface be used to render a single, or multiple sims?</param>
        /// <param name="Screen">The ThreeDScene instance with which to create this UI3DView instance.</param>
        /// <param name="StrID">The string ID for this UI3DView instance.</param>
        public UI3DView(int Width, int Height, bool SingleRenderer, ThreeDScene Screen, string StrID)
            : base(Screen)
        {
            m_Effects = new List<BasicEffect>();
            m_Width = Width;
            m_Height = Height;
            m_SingleRenderer = SingleRenderer;

            m_CurrentHeadMeshes = new List<Mesh>();
            m_HeadTextures = new List<Texture2D>();

            m_SBatch = new SpriteBatch(m_Scene.SceneMgr.Device);
            m_Scene.SceneMgr.Device.DeviceReset += new EventHandler(GraphicsDevice_DeviceReset);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Constructs a new UI3DView instance.
        /// </summary>
        /// <param name="Width">The width of this UI3DView surface.</param>
        /// <param name="Height">The height of this UI3DView surface.</param>
        /// <param name="SingleRenderer">Will this surface be used to render a single, or multiple sims?</param>
        /// <param name="Screen">The ThreeDScene instance with which to create this UI3DView instance.</param>
        /// <param name="StrID">The string ID for this UI3DView instance.</param>
        public UI3DView(int Width, int Height, bool SingleRenderer, ThreeDScene Screen, string StrID)
        {
            m_Scene = Screen;

            m_Effects        = new List <BasicEffect>();
            m_Width          = Width;
            m_Height         = Height;
            m_SingleRenderer = SingleRenderer;

            m_CurrentSims = new List <Sim>();

            m_SBatch = new SpriteBatch(m_Scene.SceneMgr.Device);
            m_Scene.SceneMgr.Device.DeviceReset += new EventHandler(GraphicsDevice_DeviceReset);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Constructs a new UI3DView instance. 
        /// </summary>
        /// <param name="Width">The width of this UI3DView surface.</param>
        /// <param name="Height">The height of this UI3DView surface.</param>
        /// <param name="SingleRenderer">Will this surface be used to render a single, or multiple sims?</param>
        /// <param name="Screen">The ThreeDScene instance with which to create this UI3DView instance.</param>
        /// <param name="StrID">The string ID for this UI3DView instance.</param>
        public UI3DView(int Width, int Height, bool SingleRenderer, ThreeDScene Screen, string StrID)
        {
            m_Scene = Screen;

            m_Effects = new List<BasicEffect>();
            m_Width = Width;
            m_Height = Height;
            m_SingleRenderer = SingleRenderer;

            m_CurrentSims = new List<Sim>();

            m_SBatch = new SpriteBatch(m_Scene.SceneMgr.Device);
            m_Scene.SceneMgr.Device.DeviceReset += new EventHandler(GraphicsDevice_DeviceReset);
        }
Ejemplo n.º 9
0
        public CoreGameScreen()
        {
            ///** City Scene **/
            var scene = new ThreeDScene();
            //scene.Camera.Position = new Vector3(0, -14.1759f, 10f);
            //scene.Camera.Position = new Vector3(0, 0, 17.0f);
            //scene.Camera.Target = Vector3.Zero;
            scene.Camera.Up = Vector3.Forward;

            var city = new CitySceneElement();

            if (PlayerAccount.CurrentlyActiveSim != null)
                city.Initialize(PlayerAccount.CurrentlyActiveSim.ResidingCity.Name);
            else //Debug purposes...
                city.Initialize("Blazing Falls");

            //city.RotationX = (float)MathUtils.DegreeToRadian(347);
            //city.Scale = new Vector3(1.24f);

            scene.Camera.Target = new Vector3(
                ((city.City.Width * city.Geom.CellWidth) / 2),
                -((city.City.Height * city.Geom.CellHeight) / 2),
                0.0f);

            scene.Camera.Position =

                Vector3.Transform(
                    new Vector3(
                        scene.Camera.Target.X,
                        scene.Camera.Target.Y,
                        city.City.Width / GameFacade.GraphicsDevice.Viewport.Width),
                    Microsoft.Xna.Framework.Matrix.CreateRotationY((float)MathUtils.DegreeToRadian(-200)));

            scene.Add(city);

            ucp = new UIUCP();
            ucp.Y = ScreenHeight - 210;
            this.Add(ucp);

            gizmo = new UIGizmo();
            gizmo.X = ScreenWidth - 500;
            gizmo.Y = ScreenHeight - 300;
            this.Add(gizmo);

            GameFacade.Scenes.AddScene(scene);
        }
        public override void Draw(GraphicsDevice device, ThreeDScene scene)
        {
            var camera = new Camera(new Vector3(0, -14.1759f, 10f), new Vector3(0, 0, 0), Vector3.Up);

            var gd = GameFacade.GraphicsDevice;

            gd.VertexDeclaration = new VertexDeclaration(gd, TerrainVertex.VertexElements);
            effect.CurrentTechnique = effect.Techniques["TerrainSplat"];

            if (zoomedIn)
            {
                effect.Parameters["xTextureBlend"].SetValue(TextureBlend);
                effect.Parameters["xTextureTerrain"].SetValue(TextureTerrain);
            }
            else
            {
                effect.Parameters["xTextureGrass"].SetValue(TextureGrass);
                effect.Parameters["xTextureSnow"].SetValue(TextureSnow);
                effect.Parameters["xTextureSand"].SetValue(TextureSand);
                effect.Parameters["xTextureRock"].SetValue(TextureRock);
                effect.Parameters["xTextureWater"].SetValue(TextureWater);
            }
            //;
            //var worldMatrix = Matrix.Identity * Matrix.CreateTranslation(transX, 0, transY) * Matrix.CreateScale(zoom) * Matrix.CreateRotationX(MathHelper.ToRadians(degs));

            effect.Parameters["xWorld"].SetValue(World);
            effect.Parameters["xView"].SetValue(scene.Camera.View);
            effect.Parameters["xProjection"].SetValue(GameFacade.Scenes.ProjectionMatrix);

            effect.Parameters["xEnableLighting"].SetValue(true);
            effect.Parameters["xAmbient"].SetValue(0.8f);
            effect.Parameters["xLightDirection"].SetValue(lightDirection);
            effect.CommitChanges();

            //GraphicsDevice.BlendState = BlendState.Opaque;

            effect.Begin();
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                Geom.Draw(gd);
                pass.End();
            }
            effect.End();
        }
        public CoreGameScreen()
        {
            ucp = new UIUCP();
            ucp.Y = ScreenHeight - 210;
            this.Add(ucp);

            gizmo = new UIGizmo();
            gizmo.X = ScreenWidth - 500;
            gizmo.Y = ScreenHeight - 300;
            this.Add(gizmo);

            ///** City Scene **/
            var scene = new ThreeDScene();
            //scene.Camera.Position = new Vector3(0, -14.1759f, 10f);
            scene.Camera.Position = new Vector3(0, 0, 17.0f);
            scene.Camera.Target = Vector3.Zero;
            scene.Camera.Up = Vector3.Up;

            ////, new Vector3(0, 0, 0), Vector3.Up
            var city = new CitySceneElement();
            city.Initialize();

            //city.RotationX = (float)MathUtils.DegreeToRadian(347);
            //city.Scale = new Vector3(1.24f);

            scene.Camera.Target = new Vector3(
                ((city.City.Width * city.Geom.CellWidth) / 2),
                -((city.City.Height * city.Geom.CellHeight) / 2),
                0.0f);

            scene.Camera.Position =

                Vector3.Transform(
                    new Vector3(
                        scene.Camera.Target.X,
                        scene.Camera.Target.Y,
                        city.City.Width / GameFacade.GraphicsDevice.Viewport.Width),
                    Microsoft.Xna.Framework.Matrix.CreateRotationY((float)MathUtils.DegreeToRadian(-200)));

            scene.Add(city);

            GameFacade.Scenes.AddScene(scene);
        }
Ejemplo n.º 12
0
        public UISim()
        {
            SimRender = new SimRenderer();
            SimRender.ID = "SimRender";

            SimScene = new ThreeDScene();
            SimScene.ID = "SimScene";
            SimScene.Camera = new Camera(Vector3.Backward * ViewScale, Vector3.Zero, Vector3.Right);
            SimScene.Add(SimRender);
            //GameFacade.Scenes.AddScene(SimScene);

            /** Default settings **/
            SimRender.Scale = new Vector3(0.6f);
            SimRender.RotationY = (float)MathUtils.DegreeToRadian(25);
            SimRender.RotationX = (float)MathUtils.DegreeToRadian(RotationStartAngle);
            //
            //var scene = new TSOClient.ThreeD.ThreeDScene();
            //scene.Add(a);
            GameFacade.Scenes.AddExternalScene(SimScene);
        }
Ejemplo n.º 13
0
 public abstract void Draw(GraphicsDevice device, ThreeDScene scene);
Ejemplo n.º 14
0
 /// <summary>
 /// Removes a scene from this SceneManager instances' list of scenes.
 /// </summary>
 /// <param name="Scene">The ThreeDScene instance to remove.</param>
 public void RemoveScene(ThreeDScene Scene)
 {
     m_Scenes.Remove(Scene);
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Adds a ThreeDScene instance to this SceneManager instance's list of scenes.
 /// </summary>
 /// <param name="Scene">The ThreeDScene instance to add.</param>
 public void AddScene(ThreeDScene Scene)
 {
     m_Scenes.Add(Scene);
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Adds a ThreeDScene instance to the scene manager but the scene manager will not render
 /// this scene. It is only added so it can be included in the debug panel
 /// </summary>
 /// <param name="Scene"></param>
 public void AddExternalScene(ThreeDScene Scene)
 {
     ExternalScenes.Add(Scene);
 }
 /// <summary>
 /// Adds a ThreeDScene instance to the scene manager but the scene manager will not render
 /// this scene. It is only added so it can be included in the debug panel
 /// </summary>
 /// <param name="Scene"></param>
 public void AddExternalScene(ThreeDScene Scene)
 {
     ExternalScenes.Add(Scene);
 }
 /// <summary>
 /// Adds a ThreeDScene instance to this SceneManager instance's list of scenes.
 /// </summary>
 /// <param name="Scene">The ThreeDScene instance to add.</param>
 public void AddScene(ThreeDScene Scene)
 {
     m_Scenes.Add(Scene);
 }
 public abstract void Draw(GraphicsDevice device, ThreeDScene scene);
Ejemplo n.º 20
0
 public ThreeDElement(ThreeDScene Scene)
 {
     m_Scene = Scene;
 }
 /// <summary>
 /// Removes a scene from this SceneManager instances' list of scenes.
 /// </summary>
 /// <param name="Scene">The ThreeDScene instance to remove.</param>
 public void RemoveScene(ThreeDScene Scene)
 {
     m_Scenes.Remove(Scene);
 }
Ejemplo n.º 22
0
        public override void Draw(GraphicsDevice device, ThreeDScene scene)
        {
            if (m_Sim == null) { return; }

            device.VertexDeclaration = new VertexDeclaration(device, VertexPositionNormalTexture.VertexElements);

            var world = World;// *Matrix.CreateRotationX(m_Rotation);

            foreach (var effect in m_Effects)
            {
                effect.World = world;//GameFacade.Scenes.WorldMatrix * Matrix.CreateScale(3.0f);// *Microsoft.Xna.Framework.Matrix.CreateTranslation(
                                // new Microsoft.Xna.Framework.Vector3(m_Sim.HeadXPos, m_Sim.HeadYPos, 0.0f));

                effect.View = scene.Camera.View;
                //effect.Projection = GameFacade.Scenes.ProjectionMatrix;
                effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.Pi / 4.0f,
                    (float)device.PresentationParameters.BackBufferWidth /
                    (float)device.PresentationParameters.BackBufferHeight,
                    1.0f, 100.0f);

                //var aspect = GameFacade.GraphicsDevice.Viewport.AspectRatio;
                /*var ratioX = 1024.0f / 1024.0f;
                var ratioY = 10.0f / 768.0f;
                var projectionX = 0.0f - (1.0f * ratioX);
                var projectionY = 0.0f - (1.0f * ratioY);
                effect.Projection = Matrix.CreatePerspectiveOffCenter(projectionX, projectionX + 1.0f, (projectionY / aspect), (projectionY+1.0f) / aspect, 1.0f, 100.0f);
                */
                effect.Projection = scene.Camera.Projection;

                effect.Texture = m_Sim.HeadTexture;
                effect.TextureEnabled = true;
                //effect.EnableDefaultLighting();

                //foreach (var technique in effect.Techniques)
                //{
                //    effect.CurrentTechnique = technique;
                    effect.CommitChanges();
                    effect.Begin();

                    foreach (var pass in effect.CurrentTechnique.Passes)
                    {
                        pass.Begin();

                        foreach (Face Fce in m_Sim.HeadMesh.Faces)
                        {
                            if (m_Sim.HeadMesh.VertexTexNormalPositions != null)
                            {
                                VertexPositionNormalTexture[] Vertex = new VertexPositionNormalTexture[3];
                                Vertex[0] = m_Sim.HeadMesh.VertexTexNormalPositions[Fce.AVertexIndex];
                                Vertex[1] = m_Sim.HeadMesh.VertexTexNormalPositions[Fce.BVertexIndex];
                                Vertex[2] = m_Sim.HeadMesh.VertexTexNormalPositions[Fce.CVertexIndex];

                                Vertex[0].TextureCoordinate = m_Sim.HeadMesh.VertexTexNormalPositions[Fce.AVertexIndex].TextureCoordinate;
                                Vertex[1].TextureCoordinate = m_Sim.HeadMesh.VertexTexNormalPositions[Fce.BVertexIndex].TextureCoordinate;
                                Vertex[2].TextureCoordinate = m_Sim.HeadMesh.VertexTexNormalPositions[Fce.CVertexIndex].TextureCoordinate;

                                GameFacade.GraphicsDevice.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, Vertex, 0, 1);
                            }
                        }

                        pass.End();
                    }

                    effect.End();
                }
        }
        private void SetSelectedScene(ThreeDScene scene)
        {
            if (scene == null)
            {
                tabCamera.Enabled = false;
                return;
            }

            tabCamera.Enabled = true;

            SelectedScene = null;

            cameraX.Value = (decimal)scene.Camera.Position.X;
            cameraY.Value = (decimal)scene.Camera.Position.Y;
            cameraZ.Value = (decimal)scene.Camera.Position.Z;

            cameraTargetX.Value = (decimal)scene.Camera.Target.X;
            cameraTargetY.Value = (decimal)scene.Camera.Target.Y;
            cameraTargetZ.Value = (decimal)scene.Camera.Target.Z;

            SelectedScene = scene;
        }