Exemplo n.º 1
0
        public CubeObject PlaceCube(CubeObject prefab, Vector3 position, Quaternion rotation)
        {
            CubeObject cubeObject = Instantiate <CubeObject>(prefab, position, rotation, transform) as CubeObject;

            cubeObject.SetRenderers();
            for (int connectionPoint = 0; connectionPoint < prefab.ConnectionPoints.Count; connectionPoint++)
            {
                cubeObject.AttachmentPoints.Add(cubeObject.transform.TransformPoint(prefab.ConnectionPoints[connectionPoint]));
            }
            cubeObjects.Add(cubeObject);

            for (int i = 0; i < cubeObject.AttachmentPoints.Count; i++)
            {
                Vector3 where = cubeObject.AttachmentPoints[i];
                CubeObject part2 = GetCube(transform.InverseTransformPoint(where));
                if ((Object)part2 != (Object)null)
                {
                    for (int j = 0; j < part2.AttachmentPoints.Count; j++)
                    {
                        Vector3    where2 = part2.AttachmentPoints[j];
                        CubeObject part3  = GetCube(transform.InverseTransformPoint(where2));
                        if ((Object)part3 != (Object)null && (Object)cubeObject == (Object)part3 && !cubeObject.ConnectedCubes.Contains(part2))
                        {
                            cubeObject.ConnectedCubes.Add(part2);
                        }
                    }
                }
            }
            foreach (CubeObject cube in cubeObject.ConnectedCubes)
            {
                cube.ConnectedCubes.Add(cubeObject);
            }
            return(cubeObject);
        }
Exemplo n.º 2
0
        public void DestroyCube(Vector3 where)
        {
            CubeObject cube = GetCube(where);

            if (cube != null)
            {
                cubeObjects.Remove(cube);

                foreach (CubeObject connection in cube.ConnectedCubes)
                {
                    connection.ConnectedCubes.Remove(connection);
                }

                Destroy(cube.gameObject);
            }
        }
Exemplo n.º 3
0
        private void Start()
        {
            CubeObject cubeObject = GetComponent <CubeObject>();

            SetSelf(ref cubeObject);
        }
Exemplo n.º 4
0
 private void SetSelf(ref CubeObject obj)
 {
     self = obj;
 }
Exemplo n.º 5
0
        public void MainLoop()
        {
            this.SettingCamera();

            this._device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.DarkBlue.ToArgb(), 1.0f, 0);

            sprite.Begin(SpriteFlags.AlphaBlend);
            sprite.Draw(_background, Vector3.Empty, new Vector3(1, 1, 1), Color.White.ToArgb());
            sprite.End();

            this._device.BeginScene();


            CheckRotateMove();

            foreach (CubeObject cube in this._clist)
            {
                cube.Render(this._device, this._x, this._y, this._z, this._scale, this._selected, this._zoomfactor);
            }

            this._font.DrawText(null, "Draw Cubes", 23, 25, Color.Black);
            this._font.DrawText(null, "Mouse X/Y:" + this._oldMousePoint.X.ToString() + "   /   " + this._oldMousePoint.Y.ToString(), 23, 35, Color.Black);
            this._font.DrawText(null, "θ/φ:" + this._lensPosTheta + "   /   " + this._lensPosPhi, 23, 45, Color.Black);
            this._font.DrawText(null, "X/Y/Z:" + this._x + "=" + Geometry.DegreeToRadian(this._x) + "   /   " + this._y + "=" + Geometry.DegreeToRadian(this._y) + "   /   " + this._z + "=" + Geometry.DegreeToRadian(this._z), 23, 55, Color.Black);
            this._font.DrawText(null, "확대:" + this._scale.X, 23, 65, Color.Black);
            this._font.DrawText(null, "선택:" + this._selected, 23, 75, Color.Black);
            this._font.DrawText(null, "방향:" + this._mouseway, 23, 85, Color.Black);
            this._font.DrawText(null, "벡터:" + this.ViewVector.X, 23, 95, Color.Black);

            Vertices = new CustomVertex.PositionTextured[9];

            foreach (CubeObject cube in _clist)
            {
                if (cube.select)
                {
                    Vertices = cube.intersectedVertices;
                }
            }

            Vector3 vtr1 = new Vector3(Vertices[0].X, Vertices[0].Y, Vertices[0].Z);
            Vector3 vtr2 = new Vector3(Vertices[1].X, Vertices[1].Y, Vertices[1].Z);
            Vector3 vtr3 = new Vector3(Vertices[2].X, Vertices[2].Y, Vertices[2].Z);

            Viewport vp = _device.Viewport;
            Matrix   vw = _device.GetTransform(TransformType.View);
            Matrix   pj = _device.GetTransform(TransformType.Projection);
            Matrix   wd = _device.GetTransform(TransformType.World);
            Matrix   vi = _device.GetTransform(TransformType.View); vi.Invert();

            ViewVector.TransformCoordinate(wd * pj * vi);

            CubeObject cubex = GetSelectedCube();

            Matrix mat = new Matrix();

            if (cubex != null)
            {
                vtr1.TransformNormal(cubex.mat); Math.Round(vtr1.X, 5); Math.Round(vtr1.Y, 5); Math.Round(vtr1.Z, 5);
                vtr2.TransformNormal(cubex.mat); Math.Round(vtr2.X, 5); Math.Round(vtr2.Y, 5); Math.Round(vtr2.Z, 5);
                vtr3.TransformNormal(cubex.mat); Math.Round(vtr3.X, 5); Math.Round(vtr3.Y, 5); Math.Round(vtr3.Z, 5);
            }

            this._font.DrawText(null, "벌트:   " + vtr1.X + "    / " + vtr1.Y + "    / " + vtr1.Z, 23, 105, Color.Black);
            this._font.DrawText(null, "벌트:   " + vtr2.X + "    / " + vtr2.Y + "    / " + vtr2.Z, 23, 115, Color.Black);
            this._font.DrawText(null, "벌트:   " + vtr3.X + "    / " + vtr3.Y + "    / " + vtr3.Z, 23, 125, Color.Black);
            this._font.DrawText(null, "벌트:   " + this.selface, 23, 135, Color.Black);

            Vector3 pos = Vector3.Empty;

            foreach (CubeObject cube in _clist)
            {
                if (cube.select)
                {
                    pos = cube.pos;
                }
            }


            this._font.DrawText(null, "벌트:   " + pos.X + "    /    " + pos.Y + "    /    " + pos.Z, 23, 145, Color.Black);


            this._device.EndScene();
            this._device.Present();

            this.initctlvar();
        }
Exemplo n.º 6
0
        public void CreateCube(Device device, string cubename, Vector3 vs, Vector3 ve)
        {
            CubeObject cube = new CubeObject(device, cubename, vs, ve);

            this._clist.Add(cube);
        }