コード例 #1
0
 /// <summary>
 /// Create a Triangle object from 3 vertex indices of variable type.
 /// </summary>
 /// <param name="index0">
 /// A TriIndex struct representing 1 of 3 vertex index types and its value.
 /// </param>
 /// <param name="index1">
 /// A TriIndex struct representing 1 of 3 vertex index types and its value.
 /// </param>
 /// <param name="index2">
 /// A TriIndex struct representing 1 of 3 vertex index types and its value.
 /// </param>
 public Triangle(TriIndex index0, TriIndex index1, TriIndex index2)
 {
     this.type0   = index0.type;
     this.type1   = index1.type;
     this.type2   = index2.type;
     this.vertex0 = 0;
     this.vertex1 = 0;
     this.vertex2 = 0;
     this.vertex0 = TriIndex.EncodeIndex(index0);
     this.vertex1 = TriIndex.EncodeIndex(index1);
     this.vertex2 = TriIndex.EncodeIndex(index2);
 }
コード例 #2
0
    private TriIndex DrawTriangleEditElement(Rect rect, TriIndexType type, ushort vertexcode)
    {
        rect = VxlGUI.GetRightColumn(rect, 0, 0.95f);
        float element_factor = 0.6f;
        float segment_width  = (rect.width - (2 * VxlGUI.SM_SPACE)) / 3;
        float unit_width     = (rect.width - (5 * VxlGUI.SM_SPACE)) / 6f;
        //Type Options
        Rect segrect = VxlGUI.GetRightElement(rect, 2, segment_width, VxlGUI.SM_SPACE, 0);

        EditorGUI.LabelField(
            VxlGUI.GetLeftColumn(segrect, 0, 1 - element_factor),
            "Type:",
            GUI.skin.GetStyle("RightDarkText")
            );
        int type_index = EditorGUI.Popup(
            VxlGUI.GetRightColumn(segrect, 0, element_factor),
            OptionIndex(type),
            _optionstrs,
            GUI.skin.GetStyle("DarkDropdown")
            );

        if (type_index >= 0 && type_index < _options.Length)
        {
            type = _options[type_index];
        }
        if (type == TriIndexType.CornerPlug || type == TriIndexType.EdgePlug)
        {
            //Axis Options
            segrect = VxlGUI.GetRightElement(rect, 1, segment_width, VxlGUI.SM_SPACE, 0);
            EditorGUI.LabelField(
                VxlGUI.GetLeftColumn(segrect, 0, 1 - element_factor),
                "Axis:",
                GUI.skin.GetStyle("RightDarkText")
                );
            string[] labels;
            if (type == TriIndexType.CornerPlug)
            {
                labels = _cornerplug_labels;
            }
            else
            {
                labels = _edgeplug_labels;
            }
            int axis_index = EditorGUI.Popup(
                VxlGUI.GetRightColumn(segrect, 0, element_factor),
                TriIndex.DecodeAxiIndex(vertexcode),
                labels,
                GUI.skin.GetStyle("DarkDropdown")
                );
            //Socket Options
            segrect = VxlGUI.GetRightElement(rect, 0, segment_width, VxlGUI.SM_SPACE, 0);
            EditorGUI.LabelField(
                VxlGUI.GetLeftColumn(segrect, 0, 1 - element_factor),
                "Socket:",
                GUI.skin.GetStyle("RightDarkText")
                );
            int socket_index = EditorGUI.IntField(
                VxlGUI.GetRightColumn(segrect, 0, element_factor),
                TriIndex.DecodeIndex(vertexcode),
                GUI.skin.GetStyle("DarkNumberField")
                );
            vertexcode = TriIndex.EncodeIndex((byte)axis_index, (byte)socket_index);
        }
        else
        {
            //Vertex Index Options
            segrect = VxlGUI.GetRightElement(rect, 0, segment_width, VxlGUI.SM_SPACE, 0);
            EditorGUI.LabelField(
                VxlGUI.GetLeftColumn(segrect, 0, 1 - element_factor),
                "Index:",
                GUI.skin.GetStyle("RightDarkText")
                );
            vertexcode = (ushort)EditorGUI.IntField(
                VxlGUI.GetRightColumn(segrect, 0, element_factor),
                vertexcode,
                GUI.skin.GetStyle("DarkNumberField")
                );
        }
        return(new TriIndex(type, vertexcode));
    }