Ejemplo n.º 1
0
        public void SetMap(string path)
        {
            FileStream   fs = new FileStream(path, FileMode.Open, FileAccess.Read);
            BinaryReader r  = new BinaryReader(fs);

            CurMap = new Map.Map();

            r.ReadInt32();

            CurMap.Read(r);

            r.Close();
            fs.Close();

            Graph   = CurMap.UpdateGraph(64, 64);
            Graph.X = (AppInfo.W / 2) - 32;
            Graph.Y = (AppInfo.H / 2) - 32;
            float mz, maz;

            mz  = 1000;
            maz = -1000;
            foreach (var n in Graph.Root.Nodes)
            {
                if (n.Z < mz)
                {
                    mz = n.Z;
                }
                if (n.Z > maz)
                {
                    maz = n.Z;
                }
            }
            Console.WriteLine("MinZ:" + mz + " MaxZ:" + maz);
            ColMap = Graph.CreateCollisionMap();
        }
Ejemplo n.º 2
0
        public void RenderShadowBuffer(SceneGraph2D graph)
        {
            if (graph.Root == null)
            {
                return;
            }
            if (SB1 == null)
            {
                CreateShadowBuffers(App.AppInfo.RW, App.AppInfo.RH);
            }

            SB1.Bind();
            Vivid.Draw.Render.Begin();
            graph.DrawNodeShadow(graph.Root);

            //LitImage.Light = Lights[0];
            //LitImage.Graph = this;
            // if (LitImage.Light != null)
            //{

            graph.ShadowImage.Bind();


            Vivid.Draw.Render.SetBlend(Vivid.Draw.BlendMode.Alpha);;

            Vivid.Draw.Render.End2D();


            graph.ShadowImage.Release();
            // }


            SB1.Release();


            SB2.Bind();

            //Graph.ShadowBuf.BB.Bind(0);

            graph.DrawShadow.Graph = graph;
            graph.DrawShadow.Light = this;


            Vivid.Draw.IntelliDraw.BeginDraw();
            Vivid.Draw.IntelliDraw.DrawImg(0, 0, Vivid.App.AppInfo.RW, Vivid.App.AppInfo.RH, SB1.BB, new Vector4(1, 1, 1f, 1), true);
            Vivid.Draw.IntelliDraw.EndDraw(graph.DrawShadow);

            SB2.Release();

            //return;


            SB1.Bind();

            Vivid.Draw.IntelliDraw.BeginDraw();
            Vivid.Draw.IntelliDraw.DrawImg(0, 0, Vivid.App.AppInfo.RW, Vivid.App.AppInfo.RH, SB2.BB, new Vector4(1, 1, 1f, 1), false);
            Vivid.Draw.IntelliDraw.EndDraw(graph.BlurShadow);

            SB1.Release();
        }
Ejemplo n.º 3
0
        public RainDrop(SceneGraph2D graph)
        {
            if (DropImg == null)
            {
                Rnd     = new Random(Environment.TickCount);
                DropImg = new Tex.Tex2D("Corona/img/fx/raindrop1.png", true);
            }
            DropSprite = new GraphSprite(DropImg, null, 16, 16);
            Graph      = graph;

            DropSprite.X = Rnd.Next(-2500, 2500);
            DropSprite.Y = Rnd.Next(-500, 1000);
            FallZ        = 0.4f + (float)Rnd.NextDouble();

            Graph.Add(DropSprite);
        }
Ejemplo n.º 4
0
        public void UpdateGraph()
        {
            float gx, gy;

            //Console.WriteLine("Updating graph.");
            if (Graph != null)
            {
                gr = Graph.Rot;
                gx = Graph.X;
                gy = Graph.Y;
                gz = Graph.Z;

                //var sb  SceneGraph.ShadowBuf;
                if (Map.Markers.Count > 0)
                {
                    int vv = 5;
                }
                Graph     = Map.UpdateGraph(Map.Layers[0].Width, Map.Layers[0].Height);
                Graph.X   = gx;
                Graph.Y   = gy;
                Graph.Rot = gr;
                Graph.Z   = gz;
                // if (Graph.ShadowBuf == null)
                {
                    //  Graph.ShadowBuf = sb;
                    //Graph.CreateShadowBuf(W, H);
                }
                // Graph.X = -32 + W / 2;
                // Graph.Y = -32 + H / 2;
            }
            else
            {
                Graph = Map.UpdateGraph(Map.Layers[0].Width, Map.Layers[0].Height);
                //if (Graph.ShadowBuf == null)
                {
                    //    Graph.CreateShadowBuf(W, H);
                }
                //Graph.X = -32 + W / 2;
                //Graph.Y = -32 + H / 2;
            }
            Changed = true;

            //Graph.X -= 370;
            //Graph.Y -= 170;
        }
Ejemplo n.º 5
0
        public void UpdateGraph()
        {
            float gx, gy;

            if (Graph != null)
            {
                gr = Graph.Rot;
                gx = Graph.X;
                gy = Graph.Y;
                gz = Graph.Z;

                //var sb  SceneGraph.ShadowBuf;
                Graph     = Map.UpdateGraph(Map.Layers[0].Width, Map.Layers[0].Height);
                Graph.X   = gx;
                Graph.Y   = gy;
                Graph.Rot = gr;
                Graph.Z   = gz;
                // if (Graph.ShadowBuf == null)
                {
                    //  Graph.ShadowBuf = sb;
                    //Graph.CreateShadowBuf(W, H);
                }
                // Graph.X = -32 + W / 2;
                // Graph.Y = -32 + H / 2;
            }
            else
            {
                Graph = Map.UpdateGraph(Map.Layers[0].Width, Map.Layers[0].Height);
                //if (Graph.ShadowBuf == null)
                {
                    //    Graph.CreateShadowBuf(W, H);
                }
                //Graph.X = -32 + W / 2;
                //Graph.Y = -32 + H / 2;
            }
            Changed = true;

            //Graph.X -= 370;
            //Graph.Y -= 170;
        }
Ejemplo n.º 6
0
        public Vivid.Scene.SceneGraph2D UpdateGraph(int tw, int th)
        {
            if (sceneChanged == false)
            {
                return(oGraph);
            }
            Vivid.Scene.SceneGraph2D Graph = oGraph;
            if (oGraph == null)
            {
                Graph = new Vivid.Scene.SceneGraph2D();
            }
            oGraph       = Graph;
            sceneChanged = false;
            float sp = 0;
            int   li = 0;

            Graph.Root = new GraphNode();
            foreach (var layer in Layers)
            {
                li++;
                for (int y = 0; y < layer.Height; y++)
                {
                    for (int x = 0; x < layer.Width; x++)
                    {
                        var tile = layer.GetTile(x, y);

                        if (tile == null)
                        {
                            if (li == 1)
                            {
                                var notile = new GraphSprite(new Tex2D("content/edit/notile.png", false), null, TileWidth, TileHeight);
                                notile.SetPos(x * TileWidth, y * TileHeight);
                                notile.TileX = x;
                                notile.TileY = y;
                                Graph.Add(notile);
                            }
                            continue;
                        }

                        var tileSpr = new GraphSprite(tile.ColorImage, tile.NormalImage, TileWidth, TileHeight);

                        tileSpr.TileX = x;
                        tileSpr.TileY = y;

                        int mx = x * TileWidth;
                        int my = y * TileHeight;



                        tileSpr.SetPos(mx, my);
                        tileSpr.Obj[0] = tile;
                        if (Lights.Count > 0)
                        {
                            tileSpr.ShadowPlane = sp;
                        }
                        Graph.Add(tileSpr);
                        if (li > 1)
                        {
                            tileSpr.CastShadow = true;
                            tileSpr.RecvShadow = false;
                        }
                    }
                }
                sp = sp + 0.1f;
            }

            NewMethod(Graph);

            if (Graph.Lights.Count != Lights.Count)
            {
                Graph.Lights.Clear();
                Graph.Add(Lights.ToArray());
            }
            // Graph.Add(Lights.ToArray());
            foreach (var l in Lights)
            {
                var lg = new GraphSprite(new Tex2D("content/edit/light.png", true), null, 64, 64);
                lg.X = l.X;
                lg.Y = l.Y;
                lg.Z = l.Z;
                //   Graph.Add(lg);
            }


            return(Graph);
        }
Ejemplo n.º 7
0
 public DebugGraph(SceneGraph2D graph)
 {
 }