Beispiel #1
0
        public FreeBrush(BrushManager manager, SceneNode node)
            : base(manager, node)
        {
            var mesh = manager.LoadAsset <Mesh>("title:Resources/Meshes/Cube.json");

            brushMesh       = new BrushMesh("BrushMesh", manager.GraphicsDevice, mesh);
            brushMesh.Color = new Vector3(1, 0, 0);
            brushMesh.Alpha = 0.5f;
            Node.Objects.Add(brushMesh);

            // 常にペイント可能。
            CanPaint = true;
        }
Beispiel #2
0
        public StickyBrush(BrushManager manager, SceneNode node)
            : base(manager, node)
        {
            var mesh = manager.LoadAsset <Mesh>("title:Resources/Meshes/Cube.json");

            brushMesh       = new BrushMesh("BrushMesh", manager.GraphicsDevice, mesh);
            brushMesh.Color = new Vector3(1, 0, 0);
            brushMesh.Alpha = 0.5f;
            Node.Objects.Add(brushMesh);

            triangleInfos = new TriangleInfo[2 * 6];

            // 原点中心の立方体をブロックのグリッドへ移動させるための行列。
            var transform = Matrix.CreateTranslation(new Vector3(0.5f));

            int i = 0;

            for (int j = 0; j < Side.Count; j++)
            {
                var side = Side.Items[j];

                var normal = side.Direction.ToVector3();

                var side1 = new Vector3(normal.Y, normal.Z, normal.X);
                var side2 = Vector3.Cross(normal, side1);

                // (0,0,0) を原点に頂点を算出。
                var v0 = (normal - side1 - side2) * 0.5f;
                var v1 = (normal - side1 + side2) * 0.5f;
                var v2 = (normal + side1 + side2) * 0.5f;
                var v3 = (normal + side1 - side2) * 0.5f;

                // ブロックのグリッドに移動。
                Vector3.Transform(ref v0, ref transform, out v0);
                Vector3.Transform(ref v1, ref transform, out v1);
                Vector3.Transform(ref v2, ref transform, out v2);
                Vector3.Transform(ref v3, ref transform, out v3);

                triangleInfos[i] = new TriangleInfo(side)
                {
                    Triangle = new Triangle(v0, v1, v2)
                };

                triangleInfos[i + 1] = new TriangleInfo(side)
                {
                    Triangle = new Triangle(v0, v2, v3)
                };

                i += 2;
            }
        }