public override void Construct()
 {
     Cube = new ExtCube(transform.position,
                        transform.rotation,
                        transform.lossyScale);
 }
Exemple #2
0
        ///
        ///      6 ------------ 7
        ///    / |    3       / |
        ///  5 ------------ 8   |
        ///  |   |          |   |
        ///  | 5 |     6    | 2 |     ------8-----
        ///  |   |   1      |   |
        ///  |  2 ----------|-- 3
        ///  |/       4     | /     |       3      |
        ///  1 ------------ 4
        ///
        ///          6 ------6----- 5 ------2----- 8 -----10----- 7       -
        ///          |              |              |              |
        ///          |              |              |              |
        ///          5      5       1       1      3       2      11       6       |
        ///          |              |              |              |
        ///          |              |              |              |
        ///          2 ------7----- 1 ------4----- 4 ------12---- 3       -
        ///
        ///
        ///                         |       4      |
        ///
        ///
        ///                           ------9-----
        public static GravityOverrideCube DrawCube(ExtCube cube, GravityOverrideCube cubeGravity, Color color, out bool hasChanged)
        {
            hasChanged = false;
            bool changed = hasChanged;

            float sizeLine  = cube.LocalScale.magnitude / 35;
            float sizePoint = cube.LocalScale.magnitude / 30;

            Color colorQuad = new Color(color.r, color.g, color.b, color.a * 0.5f);
            Color colorLine = new Color(color.r, color.g, color.b, color.a * 0.8f);

            //we have to order the button from the point of view of the camera
            FloatRange[] facesArranged = ExtCube.GetOrdersOfFaceFromPoint(cube, ExtSceneView.GetSceneViewCameraTransform().position);
            for (int i = facesArranged.Length - 1; i >= 0; i--)
            {
                switch (facesArranged[i].Min)
                {
                case 1:
                    cubeGravity.Face1  = DrawQuadFace(new ExtQuad(cube.P1, cube.P5, cube.P8, cube.P4), cubeGravity.Face1, false, colorQuad, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Line1  = DrawLineTrunk(cubeGravity.Line1, cube.P1, cube.P5, colorLine, sizeLine, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Line2  = DrawLineTrunk(cubeGravity.Line2, cube.P5, cube.P8, colorLine, sizeLine, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Line3  = DrawLineTrunk(cubeGravity.Line3, cube.P8, cube.P4, colorLine, sizeLine, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Line4  = DrawLineTrunk(cubeGravity.Line4, cube.P4, cube.P1, colorLine, sizeLine, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Point1 = DrawPoint(cubeGravity.Point1, cube.P1, color, sizePoint, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Point5 = DrawPoint(cubeGravity.Point5, cube.P5, color, sizePoint, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Point8 = DrawPoint(cubeGravity.Point8, cube.P8, color, sizePoint, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Point4 = DrawPoint(cubeGravity.Point4, cube.P4, color, sizePoint, out changed); hasChanged = (changed) ? true : hasChanged;
                    break;

                case 2:
                    cubeGravity.Face2  = DrawQuadFace(new ExtQuad(cube.P4, cube.P8, cube.P7, cube.P3), cubeGravity.Face2, false, colorQuad, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Line3  = DrawLineTrunk(cubeGravity.Line3, cube.P4, cube.P8, colorLine, sizeLine, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Line10 = DrawLineTrunk(cubeGravity.Line10, cube.P8, cube.P7, colorLine, sizeLine, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Line11 = DrawLineTrunk(cubeGravity.Line11, cube.P7, cube.P3, colorLine, sizeLine, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Line12 = DrawLineTrunk(cubeGravity.Line12, cube.P3, cube.P4, colorLine, sizeLine, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Point4 = DrawPoint(cubeGravity.Point4, cube.P4, color, sizePoint, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Point8 = DrawPoint(cubeGravity.Point8, cube.P8, color, sizePoint, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Point7 = DrawPoint(cubeGravity.Point7, cube.P7, color, sizePoint, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Point3 = DrawPoint(cubeGravity.Point3, cube.P3, color, sizePoint, out changed); hasChanged = (changed) ? true : hasChanged;
                    break;

                case 3:
                    cubeGravity.Face3  = DrawQuadFace(new ExtQuad(cube.P5, cube.P6, cube.P7, cube.P8), cubeGravity.Face3, false, colorQuad, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Line6  = DrawLineTrunk(cubeGravity.Line6, cube.P5, cube.P6, colorLine, sizeLine, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Line8  = DrawLineTrunk(cubeGravity.Line8, cube.P6, cube.P7, colorLine, sizeLine, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Line10 = DrawLineTrunk(cubeGravity.Line10, cube.P7, cube.P8, colorLine, sizeLine, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Line2  = DrawLineTrunk(cubeGravity.Line2, cube.P5, cube.P8, colorLine, sizeLine, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Point5 = DrawPoint(cubeGravity.Point5, cube.P5, color, sizePoint, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Point6 = DrawPoint(cubeGravity.Point6, cube.P6, color, sizePoint, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Point7 = DrawPoint(cubeGravity.Point7, cube.P7, color, sizePoint, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Point8 = DrawPoint(cubeGravity.Point8, cube.P8, color, sizePoint, out changed); hasChanged = (changed) ? true : hasChanged;
                    break;

                case 4:
                    cubeGravity.Face4  = DrawQuadFace(new ExtQuad(cube.P2, cube.P1, cube.P4, cube.P3), cubeGravity.Face4, false, colorQuad, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Line7  = DrawLineTrunk(cubeGravity.Line7, cube.P2, cube.P1, colorLine, sizeLine, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Line4  = DrawLineTrunk(cubeGravity.Line4, cube.P1, cube.P4, colorLine, sizeLine, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Line12 = DrawLineTrunk(cubeGravity.Line12, cube.P4, cube.P3, colorLine, sizeLine, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Line9  = DrawLineTrunk(cubeGravity.Line9, cube.P2, cube.P3, colorLine, sizeLine, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Point2 = DrawPoint(cubeGravity.Point2, cube.P2, color, sizePoint, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Point1 = DrawPoint(cubeGravity.Point1, cube.P1, color, sizePoint, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Point4 = DrawPoint(cubeGravity.Point4, cube.P4, color, sizePoint, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Point3 = DrawPoint(cubeGravity.Point3, cube.P3, color, sizePoint, out changed); hasChanged = (changed) ? true : hasChanged;
                    break;

                case 5:
                    cubeGravity.Face5  = DrawQuadFace(new ExtQuad(cube.P2, cube.P6, cube.P5, cube.P1), cubeGravity.Face5, false, colorQuad, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Line5  = DrawLineTrunk(cubeGravity.Line5, cube.P2, cube.P6, colorLine, sizeLine, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Line6  = DrawLineTrunk(cubeGravity.Line6, cube.P6, cube.P5, colorLine, sizeLine, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Line1  = DrawLineTrunk(cubeGravity.Line1, cube.P5, cube.P1, colorLine, sizeLine, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Line7  = DrawLineTrunk(cubeGravity.Line7, cube.P1, cube.P2, colorLine, sizeLine, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Point2 = DrawPoint(cubeGravity.Point2, cube.P2, color, sizePoint, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Point6 = DrawPoint(cubeGravity.Point6, cube.P6, color, sizePoint, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Point5 = DrawPoint(cubeGravity.Point5, cube.P5, color, sizePoint, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Point1 = DrawPoint(cubeGravity.Point1, cube.P1, color, sizePoint, out changed); hasChanged = (changed) ? true : hasChanged;
                    break;

                case 6:
                    cubeGravity.Face6  = DrawQuadFace(new ExtQuad(cube.P3, cube.P7, cube.P6, cube.P2), cubeGravity.Face6, false, colorQuad, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Line11 = DrawLineTrunk(cubeGravity.Line11, cube.P3, cube.P7, colorLine, sizeLine, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Line8  = DrawLineTrunk(cubeGravity.Line8, cube.P7, cube.P6, colorLine, sizeLine, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Line5  = DrawLineTrunk(cubeGravity.Line5, cube.P6, cube.P2, colorLine, sizeLine, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Line9  = DrawLineTrunk(cubeGravity.Line9, cube.P3, cube.P2, colorLine, sizeLine, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Point3 = DrawPoint(cubeGravity.Point3, cube.P3, color, sizePoint, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Point7 = DrawPoint(cubeGravity.Point7, cube.P7, color, sizePoint, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Point6 = DrawPoint(cubeGravity.Point6, cube.P6, color, sizePoint, out changed); hasChanged = (changed) ? true : hasChanged;
                    cubeGravity.Point2 = DrawPoint(cubeGravity.Point2, cube.P2, color, sizePoint, out changed); hasChanged = (changed) ? true : hasChanged;
                    break;
                }
            }
            return(cubeGravity);
        }