Esempio n. 1
0
    private static MessagePackObject WriteEdge(VoxelEdge edge, int edgeI)
    {
        var edgeList = new List <MessagePackObject>();

        edgeList.Add(edgeI);
        edgeList.Add(edge.bevel);
        return(new MessagePackObject(edgeList));
    }
Esempio n. 2
0
    public override void WindowGUI()
    {
        if (voxelArray.selectionChanged)
        {
            voxelArray.selectionChanged = false;
            voxelEdge = voxelArray.GetSelectedBevel();
        }

        GUILayout.Label("Bevel:", GUIStyleSet.instance.labelTitle);

        if (!voxelArray.SomethingIsSelected())
        {
            GUILayout.Label("(none selected)");
            return;
        }

        TutorialGUI.TutorialHighlight("bevel shape");
        GUILayout.Label("Shape:");
        var newBevelType = (VoxelEdge.BevelType)GUILayout.SelectionGrid((int)voxelEdge.bevelType,
                                                                        new Texture[] {
            GUIIconSet.instance.no,
            GUIIconSet.instance.bevelIcons.flat,
            GUIIconSet.instance.bevelIcons.curve,
            GUIIconSet.instance.bevelIcons.square,
            GUIIconSet.instance.bevelIcons.stair2,
            GUIIconSet.instance.bevelIcons.stair4
        },
                                                                        3, GUIStyleSet.instance.buttonTab);

        TutorialGUI.ClearHighlight();

        TutorialGUI.TutorialHighlight("bevel size");
        GUILayout.Label("Size:");
        var newBevelSize = (VoxelEdge.BevelSize)GUILayout.SelectionGrid((int)voxelEdge.bevelSize,
                                                                        new Texture[] {
            GUIIconSet.instance.bevelIcons.quarter,
            GUIIconSet.instance.bevelIcons.half,
            GUIIconSet.instance.bevelIcons.full
        },
                                                                        3, GUIStyleSet.instance.buttonTab);

        TutorialGUI.ClearHighlight();

        if (newBevelType != voxelEdge.bevelType || newBevelSize != voxelEdge.bevelSize)
        {
            voxelEdge.bevelType = newBevelType;
            voxelEdge.bevelSize = newBevelSize;
            voxelArray.BevelSelectedEdges(voxelEdge);
        }
    }
Esempio n. 3
0
    private static MessagePackObject WriteVoxel(Voxel voxel,
                                                Dictionary <Material, int> materials, Dictionary <Material, int> overlays,
                                                Dictionary <Substance, int> substances)
    {
        var voxelList = new List <MessagePackObject>();

        voxelList.Add(WriteVector3Int(voxel.position));

        var facesList = new List <MessagePackObject>();

        for (int faceI = 0; faceI < voxel.faces.Length; faceI++)
        {
            VoxelFace face = voxel.faces[faceI];
            if (face.IsEmpty())
            {
                continue;
            }
            facesList.Add(WriteFace(face, faceI, materials, overlays));
        }
        voxelList.Add(new MessagePackObject(facesList));

        if (voxel.substance != null)
        {
            voxelList.Add(substances[voxel.substance]);
        }
        else
        {
            voxelList.Add(-1);
        }

        var edgesList = new List <MessagePackObject>();

        for (int edgeI = 0; edgeI < voxel.edges.Length; edgeI++)
        {
            VoxelEdge edge = voxel.edges[edgeI];
            if (!edge.hasBevel)
            {
                continue;
            }
            edgesList.Add(WriteEdge(edge, edgeI));
        }
        voxelList.Add(new MessagePackObject(edgesList));

        StripDataList(voxelList,
                      new bool[] { false, facesList.Count == 0, voxel.substance == null, edgesList.Count == 0 });
        return(new MessagePackObject(voxelList));
    }