Esempio n. 1
0
 public static void show(Brick brick)
 {
     foreach (Block block in brick.getBlocks())
     {
         show(block);
     }
 }
Esempio n. 2
0
 public void addBrick(Brick brick, Vector3 pos)
 {
     foreach (Block block in brick.getBlocks())
     {
         addBlock(block, pos + block.getPos());
     }
 }
Esempio n. 3
0
 public void addBrick(Brick brick)
 {
     foreach (Block block in brick.getBlocks())
     {
         addBlock(block, brick.getPos() + block.getPos());
     }
 }
Esempio n. 4
0
 public Brick(Brick brick)
 {
     brickBlocks = new List<Block>(brick.brickBlocks.Count);
     foreach (Block block in brick.brickBlocks)
     {
         brickBlocks.Add(new Block(block));
     }
     this.position = new Vector3(brick.position.X, brick.position.Y, position.Z);
     box = Mesh.Box(brick.device, 1, 1, 1);
 }
Esempio n. 5
0
 protected override void OnKeyDown(KeyEventArgs e)
 {
     bool hasSetColor = false;
     bool hasChangedBrick = false;
     switch (e.KeyCode)
     {
         case Keys.D1:
             hasChangedBrick = true;
             testID = 1;
             break;
         case Keys.D2:
             hasChangedBrick = true;
             testID = 2;
             break;
         case Keys.D0:
             hasChangedBrick = true;
             testID = 0;
             break;
         case Keys.W:
             brickPos.Z += 1;
             break;
         case Keys.A:
             brickPos.X -= 1;
             break;
         case Keys.S:
             brickPos.Z -= 1;
             break;
         case Keys.D:
             brickPos.X += 1;
             break;
         case Keys.Q:
             brickPos.Y += 1;
             break;
         case Keys.E:
             brickPos.Y -= 1;
             break;
         case Keys.C:
             holdBrick.rotateY(90);
             Log.show(holdBrick);
             break;
         case Keys.Z:
             holdBrick.rotateZ(90);
             break;
         case Keys.X:
             holdBrick.rotateX(90);
             break;
         case Keys.L:
             Log.show(mainScene.getBlock(delPos));
             break;
         case Keys.I:
             Log.show(mainScene.getBlockNum());
             break;
         case Keys.NumPad8:
             delPos.Z += 1;
             break;
         case Keys.NumPad4:
             delPos.X -= 1;
             break;
         case Keys.NumPad2:
             delPos.Z -= 1;
             break;
         case Keys.NumPad6:
             delPos.X += 1;
             break;
         case Keys.NumPad9:
             delPos.Y += 1;
             break;
         case Keys.NumPad3:
             delPos.Y -= 1;
             break;
         case Keys.NumPad5:
             mainScene.removeBlock(delPos);
             break;
         case Keys.NumPad0:
             mainScene.removeBlock(delPos);
             break;
         case Keys.Space:
             mainScene.addBrick(holdBrick);
             Console.WriteLine((int)(brickPos.X) + "," + (int)(brickPos.Y) + "," + (int)(brickPos.Z));
             break;
         case Keys.R:
             mainScene.reset();
             break;
         case Keys.Insert:
             holdColor = Color.FromArgb(
                 holdColor.R < 255 - 5 ? (holdColor.R + 5) : 255,
                 holdColor.G,
                 holdColor.B);
             hasSetColor = true;
             break;
         case Keys.Delete:
             holdColor = Color.FromArgb(
                 holdColor.R > 5 ? (holdColor.R - 5) : 0,
                 holdColor.G,
                 holdColor.B);
             hasSetColor = true;
             break;
         case Keys.Home:
             holdColor = Color.FromArgb(
                 holdColor.R,
                 holdColor.G < 255 - 5 ? (holdColor.G + 5) : 255,
                 holdColor.B);
             hasSetColor = true;
             break;
         case Keys.End:
             holdColor = Color.FromArgb(
                 holdColor.R,
                 holdColor.G > 5 ? (holdColor.G - 5) : 0,
                 holdColor.B);
             hasSetColor = true;
             break;
         case Keys.PageUp:
             holdColor = Color.FromArgb(
                 holdColor.R,
                 holdColor.G,
                 holdColor.B < 255 - 5 ? (holdColor.B + 5) : 255);
             hasSetColor = true;
             break;
         case Keys.PageDown:
             holdColor = Color.FromArgb(
                  holdColor.R,
                  holdColor.G,
                  holdColor.B > 5 ? (holdColor.B - 5) : 0);
             hasSetColor = true;
             break;
         default:
             Log.show(brickPos);
             break;
     }
     if (hasSetColor){
         ColorPanel.BackColor = holdColor;
         holdBrick.setColor(holdColor);
         testBrick.setColor(holdColor);
     }
     if (hasChangedBrick)
     {
         holdBrick = new Brick(device, testID);
         testBrick = new Brick(brickDevice, testID);
     }
     setPosLabel();
     this.Render();
 }
Esempio n. 6
0
        public void OnCreateDevice(object sender, EventArgs e)
        {
            Direct3D.Device dev = (Direct3D.Device)sender;
            // Now Create the VB
            vertexBuffer = new VertexBuffer(typeof(CustomVertex.PositionNormalColored),
                 bufferLen, dev, Usage.WriteOnly, CustomVertex.PositionNormalColored.Format, Pool.Default);
            vertexBuffer.Created += new System.EventHandler(this.OnCreateVertexBuffer);
            this.OnCreateVertexBuffer(vertexBuffer, null);

            showPos = Mesh.Sphere(dev, 0.15f, 10, 10);
            showPosMtrl.Diffuse = Color.YellowGreen;
            showPosMtrl.Ambient = Color.Wheat;
            showDelPos = Mesh.Sphere(dev, 0.15f, 10, 10);
            showDelPosMtrl.Diffuse = Color.Red;
            showDelPosMtrl.Ambient = Color.White;

            mainScene = new Scene(dev);
            holdBrick = new Brick(dev, testID);
            holdColor = holdBrick.getColor(0);
            ColorPanel.BackColor = holdColor;

            //holdBrick.setAphla(true);
        }
Esempio n. 7
0
 public void OnCreateBrickDevice(object sender, EventArgs e)
 {
     Direct3D.Device dev = (Direct3D.Device)sender;
     testBrick = new Brick(dev, testID);
     brickCamPos = testBrick.getMaxPos() * 2;
     brickCamPos.X += (brickCamPos.X == 0) ? 4 : 0;
     brickCamPos.Y += (brickCamPos.Y == 0) ? 4 : 0;
     brickCamPos.Z += (brickCamPos.Z == 0) ? 4 : 0;
 }
Esempio n. 8
0
 public void addTmpBricks(Brick brick, Vector3 pos)
 {
     Brick tmpBrick = new Brick(device);
     tmpBrick.setPos(pos);
     this.addBrick(tmpBrick);
 }