Beispiel #1
0
        protected Scene3D(MasterRenderer3D renderer, Canvas canvas, World3D world, Space3D space) :
            base(canvas, world, space)
        {
            Debug.Assert(renderer != null, "3D scenes must be created with a non-null renderer.");

            Renderer = renderer;
        }
Beispiel #2
0
        private static void Plane(Space3D faces, float x1, float y1, float x2, float y2, float h, int maxGradient)
        {
            Point3D p0 = new Point3D(x1, y1, Form1.Func(x1, y1));
            Point3D p1 = new Point3D(x1, y2, Form1.Func(x1, y2));
            Point3D p2 = new Point3D(x2, y2, Form1.Func(x2, y2));
            Point3D p3 = new Point3D(x2, y1, Form1.Func(x2, y1));

            float z = (float)(Point3D.IntToMm(p0.Z + p1.Z + p2.Z + p3.Z) / 4f);

            int c = 0;

            if (z < 0f)
            {
                c = 0;
            }
            else if (z > h)
            {
                c = maxGradient;
            }
            else
            {
                c = (int)(z / h * (float)maxGradient);
            }

            faces.Rectangle(c, p0, p1, p2, p3);
        }
Beispiel #3
0
        private void DrawText()
        {
            Space3D space = new Space3D();

            // Prepare text points and lines
            Text3D text = Text3D.FromString("This is a test string...", new Font("Times New Roman", 24), 10f, FontStyle.Regular, 50);

            // Set color for tag 1, if color is need to be specified directly use 0x7f000000 | rgb color (0xrrggbb)
            space.SetColor(0, Color.Black);
            space.Text(0, text, Text3DLocation.XY, Text3DFlip.None, 10f, 10f, 10f);

            text = Text3D.FromString("This is another test string...", new Font("Arial", 24), 10f, FontStyle.Bold, 50);
            space.Text(Form1.ColorToTag(Color.Orange), text, Text3DLocation.XZ, Text3DFlip.None, 10f, 10f, 10f);


            space.SetColor(1, Color.SandyBrown);
            space.SetColor(2, Color.RoyalBlue);
            space.SetColor(3, Color.SeaGreen);
            for (int i = 0; i < 5; i++)
            {
                text = Text3D.FromString(String.Format("String #{0}", i + 1), new Font("Courier New", 24), 10f, FontStyle.Italic, 50);
                space.Text(i % 4, text, Text3DLocation.YZ, Text3DFlip.None, 10f, 10f * (float)i, 10f);
            }


            this.view.Space = space;
        }
Beispiel #4
0
 public View3D()
 {
     InitializeComponent();
     this.space          = null;
     this.angleX         = this.angleY = this.angleZ = 0f;
     this.DoubleBuffered = true;
 }
        public void No_Objects_Should_Not_Collide()
        {
            var space            = new Space3D();
            var collisionService = new CollisionService();
            var result           = collisionService.Collide(space);

            Assert.False(result.IsCollision);
        }
        public void One_Object_Should_Not_Collide()
        {
            var space = new Space3D();

            space.AddShape(new Cube(2), new Position3D(1, 2, 3));
            var collisionService = new CollisionService();
            var result           = collisionService.Collide(space);

            Assert.False(result.IsCollision);
            Assert.Equal(0, result.CollisionVolume);
        }
Beispiel #7
0
        public Space3D <Mesh> Completed()
        {
            var system = new Space3D <Mesh>();

            foreach (var work in processed)
            {
                var mesh = Compile(work.Fab);
                system.Set(work.Blocks.Coordinate, mesh);
            }
            processed.Clear();
            return(system);
        }
Beispiel #8
0
    private void Start()
    {
        radius      = new Vector3Int(16, 3, 16);
        chunks      = new Space3D <Chunk>();
        generators  = new Space3D <ChunkGenerator>();
        chunkBlocks = new Space3D <ChunkBlocks>();
        factory     = new ChunkFactory();

        var chunk = player.Chunk();

        generators.Set(MathHelper.Anchor(chunk.x, chunk.y, chunk.z, REGION), start);

        Ping(player.Chunk());
        for (int i = 0; i < STARTUP_PROCESSED_CHUNKS; i++)
        {
            factory.Process(player.Chunk());
        }
    }
Beispiel #9
0
        private static void DrawScale(Space3D faces, float scaleSize, DrawAxis axis)
        {
            faces.Line(100, 0, 0, 0, scaleSize, axis);
            faces.Line(100, 0, scaleSize, scaleSize, scaleSize, axis);
            faces.Line(100, scaleSize, scaleSize, scaleSize, 0, axis);
            faces.Line(100, scaleSize, 0, 0, 0, axis);

            int steps = 10;

            float step = scaleSize / (float)steps;

            float x = step;

            for (int i = 1; i <= 9; i++)
            {
                faces.Line(100, x, 0, x, scaleSize, axis);
                faces.Line(100, 0, x, scaleSize, x, axis);
                x += step;
            }
        }
Beispiel #10
0
        private void DrawChart()
        {
            Space3D space = new Space3D();

            space.SetColor(100, Color.LightGray);

            float h = 100f;

            Form1.DrawScale(space, h, DrawAxis.X);
            Form1.DrawScale(space, h, DrawAxis.Y);
            Form1.DrawScale(space, h, DrawAxis.Z);

            int steps = 40;

            Color[] gradient = ColorUtils.CreateGradient(Color.Red, Color.Green, steps, ColorGradientFlags.Empty, 0.5f);
            for (int i = 0; i < gradient.Length; i++)
            {
                space.SetColor(i, gradient[i]);
            }


            float step = h / (float)steps;

            float x0 = 0f;

            for (int i = 0; i < steps; i++)
            {
                float y0 = 0f;
                float x1 = x0 + step;
                for (int j = 0; j < steps; j++)
                {
                    float y1 = y0 + step;
                    Form1.Plane(space, x0, y0, x1, y1, h, gradient.Length - 1);
                    y0 = y1;
                }
                x0 = x1;
            }


            this.view.Space = space;
        }
Beispiel #11
0
 public record BoxOn(bool On, Space3D Box);
Beispiel #12
0
 public ChunkFactory()
 {
     queue     = new Space3D <WorkItem>();
     processed = new Queue <WorkItem>();
 }