示例#1
0
        public WorkManager(int bwidth, int bheight, int bdepth, int offsetX, int offsetY, int offsetZ, GLManager glmanager)
        {
            _glmanager  = glmanager;
            blockOffset = new Tuple <int, int, int>(offsetX, offsetY, offsetZ);
            blockWidth  = bwidth;
            blockHeight = bheight;
            blockDepth  = bdepth;
            blockw      = 1 / (float)blockWidth;
            blockh      = 1 / (float)blockHeight;
            blockd      = 1 / (float)blockDepth;
            nodeCube    = new Node[blockWidth * blockHeight * blockDepth];

            //populate the cube with nodes
            for (int d = 0; d < blockDepth; d++)
            {
                for (int w = 0; w < blockWidth; w++)
                {
                    for (int h = 0; h < blockHeight; h++)
                    {
                        nodeCube[w + blockWidth * (h + blockHeight * d)] = new NormalNode(w, h, d, (w + blockWidth * (h + blockHeight * d)));
                    }
                }
            }

            List <jsonConnection> jsonConnections;
            var serializer = new JsonSerializer();

            using (var re = File.OpenText("nodes.json"))
                using (var reader = new JsonTextReader(re))
                {
                    jsonConnections = serializer.Deserialize <List <jsonConnection> >(reader);
                }

            //cycle through every node in the cube, creating all connections from json for each of them
            for (byte d = 0; d < blockDepth - 1; d++)
            {
                for (byte w = 0; w < blockWidth; w++)
                {
                    for (byte h = 0; h < blockHeight; h++)
                    {
                        Node p = nodeCube[(w) + blockWidth * ((h) + blockHeight * (d))];
                        foreach (jsonConnection conn in jsonConnections)
                        {
                            //check that the child of the connection is inside the cube
                            if (d + conn.z >= 0 && d + conn.z < blockDepth)
                            {
                                if (w + conn.x >= 0 && w + conn.x < blockWidth)
                                {
                                    if (h + conn.y >= 0 && h + conn.y < blockHeight)
                                    {
                                        Connect(p, nodeCube[(w + conn.x) + blockWidth * ((h + conn.y) + blockHeight * (d + conn.z))], conn.weight);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            _workGenerator = new FiringWorkGenerator(ref _fireQueue, ref _renderQueue, blockOffset, nodeCube);
        }
示例#2
0
        public Form1()
        {
            glmanager = new GLManager();

            InitializeComponent();
            glmanager.SetGL(this.openGLCtrl1.OpenGL);
            cycleTimer.Elapsed += new ElapsedEventHandler(DisplayTimeEvent);
            cycleTimer.Interval = 1;
            opTimer.Elapsed    += new ElapsedEventHandler(OpTimeEvent);
            opTimer.Interval    = 1000;

            for (int d = 0; d < blockCountZ; d++)
            {
                for (int w = 0; w < blockCountX; w++)
                {
                    for (int h = 0; h < blockCountY; h++)
                    {
                        managers.Add(new WorkManager(blockWidth, blockHeight, blockDepth, w, h, d, glmanager));
                    }
                }
            }

            taskArray = new Task[managers.Count];

            cycleTimer.Start();
            opTimer.Start();
        }
示例#3
0
        public Form1()
        {
            glmanager = new GLManager();

            InitializeComponent();
            glmanager.SetGL(this.openGLCtrl1.OpenGL);
            cycleTimer.Elapsed += new ElapsedEventHandler(DisplayTimeEvent);
            cycleTimer.Interval = 1;
            opTimer.Elapsed += new ElapsedEventHandler(OpTimeEvent);
            opTimer.Interval = 1000;

            for (int d = 0; d < blockCountZ; d++)
            {
                for (int w = 0; w < blockCountX; w++)
                {
                    for (int h = 0; h < blockCountY; h++)
                    {
                        managers.Add(new WorkManager(blockWidth, blockHeight, blockDepth, w, h, d, glmanager));
                    }
                }
            }

            taskArray = new Task[managers.Count];

            cycleTimer.Start();
            opTimer.Start();
        }
示例#4
0
        public WorkManager(int bwidth, int bheight, int bdepth, int offsetX, int offsetY, int offsetZ, GLManager glmanager)
        {
            _glmanager = glmanager;
            blockOffset = new Tuple<int, int, int>(offsetX, offsetY, offsetZ);
            blockWidth = bwidth;
            blockHeight = bheight;
            blockDepth = bdepth;
            blockw = 1 / (float)blockWidth;
            blockh = 1 / (float)blockHeight;
            blockd = 1 / (float)blockDepth;
            nodeCube = new Node[blockWidth * blockHeight * blockDepth];

            //populate the cube with nodes
            for (int d = 0; d < blockDepth; d++)
            {
                for (int w = 0; w < blockWidth; w++)
                {
                    for (int h = 0; h < blockHeight; h++)
                    {
                        nodeCube[w + blockWidth * (h + blockHeight * d)] = new NormalNode(w, h, d, (w + blockWidth * (h + blockHeight * d)));
                    }
                }
            }

            List<jsonConnection> jsonConnections;
            var serializer = new JsonSerializer();
            using (var re = File.OpenText("nodes.json"))
            using (var reader = new JsonTextReader(re))
            {
                jsonConnections = serializer.Deserialize<List<jsonConnection>>(reader);
            }

            //cycle through every node in the cube, creating all connections from json for each of them
            for (byte d = 0; d < blockDepth - 1; d++)
            {
                for (byte w = 0; w < blockWidth; w++)
                {
                    for (byte h = 0; h < blockHeight; h++)
                    {
                        Node p = nodeCube[(w) + blockWidth * ((h) + blockHeight * (d))];
                        foreach (jsonConnection conn in jsonConnections)
                        {
                            //check that the child of the connection is inside the cube
                            if(d+conn.z>=0 && d+conn.z<blockDepth){
                                if(w+conn.x>=0 && w+conn.x<blockWidth){
                                    if(h+conn.y>=0 && h+conn.y<blockHeight){
                                        Connect(p, nodeCube[(w+conn.x) + blockWidth * ((h+conn.y) + blockHeight * (d+conn.z))],conn.weight);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            _workGenerator = new FiringWorkGenerator(ref _fireQueue, ref _renderQueue, blockOffset,nodeCube);
        }