示例#1
0
            public Box Parse(string line)
            {
                string[] components = line.Split('|');
                if (components.Length != 2)
                {
                    throw new Exception($"Wrong box line passed: {line}");
                }
                string  type     = components[0];
                Vector3 position = ParseVector3(components[1]);
                var     box      = BoxFactory.CreateBox(type, position);

                return(box);
            }
示例#2
0
        public List <Box> GeneratePlane(string type, Vector3 center, int width, int height)
        {
            List <Box> list     = new List <Box>();
            float      distance = 1f;

            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    Vector3 position = new Vector3(distance * (j - width * 0.5f) + center.X + 0.5f,
                                                   center.Y + 0.5f,
                                                   distance * (i - height * 0.5f) + center.Z + 0.5f);
                    Box box = BoxFactory.CreateBox(type, position);
                    list.Add(box);
                }
            }
            return(list);
        }
示例#3
0
        public void PerformRightHandAction()
        {
            if (world == null)
            {
                return;
            }
            Ray ray = GetCameraRay();
            Box box = world.RayCast(ray);

            if (box == null)
            {
                return;
            }
            Vector3 position = world.RaycastToNearestPoint(ray, box);
            Box     newBox   = BoxFactory.CreateBox(selectedBoxType, position);

            world.Add(newBox);
            if (dlgt != null)
            {
                dlgt.OnCreateBox(newBox);
            }
        }
示例#4
0
        public List <Box> GenerateSphere(string type, Vector3 center, int radius)
        {
            List <Box> list     = new List <Box>();
            float      distance = 1f;

            for (int x = -radius; x <= radius; x++)
            {
                for (int y = -radius; y <= radius; y++)
                {
                    for (int z = -radius; z <= radius; z++)
                    {
                        if (Math.Abs(x * x + y * y + z * z - radius * radius) < 5)
                        {
                            Vector3 position = new Vector3(distance * x + center.X + 0.5f,
                                                           distance * y + center.Y + 0.5f,
                                                           distance * z + center.Z + 0.5f);
                            Box box = BoxFactory.CreateBox(type, position);
                            list.Add(box);
                        }
                    }
                }
            }
            return(list);
        }