Ejemplo n.º 1
0
 private int GetVertexCount(TriIndexType type)
 {
     if (target == null)
     {
         return(0);
     }
     if (type == TriIndexType.Vertex)
     {
         if (target.vertices != null)
         {
             return(target.vertices.Count);
         }
     }
     else if (type == TriIndexType.CornerPlug)
     {
         if (target.hasCornerPlug)
         {
             return(CountList(target.cornerplugs));
         }
     }
     else if (type == TriIndexType.EdgePlug)
     {
         if (target.hasEdgePlug)
         {
             return(CountList(target.edgeplugs));
         }
     }
     return(0);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates and initializes a specified type of TriIndex,
 /// encoding version.
 /// </summary>
 /// <param name="type">
 /// A TriIndexType variable that specifies what kind of
 /// TriIndex should be created and initialized.
 /// </param>
 /// <param name="vertex_index">
 /// A ushort to be encoded depending on the type of
 /// TriIndex created.
 /// </param>
 public TriIndex(TriIndexType type, ushort vertex_index)
 {
     this.type         = type;
     this.axi_index    = 0;
     this.socket_index = 0;
     this.axi_index    = DecodeAxiIndex(vertex_index);
     this.socket_index = DecodeIndex(vertex_index);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates and initializes a "Vertex" type TriIndex.
 /// </summary>
 /// <param name="vertex_index">
 /// A ushort that represents the index of a vertex.
 /// </param>
 public TriIndex(ushort vertex_index)
 {
     this.type         = TriIndexType.Vertex;
     this.axi_index    = 0;
     this.socket_index = 0;
     this.axi_index    = DecodeAxiIndex(vertex_index);
     this.socket_index = DecodeIndex(vertex_index);
 }
Ejemplo n.º 4
0
 public Triangle(TriIndexType type0, TriIndexType type1, TriIndexType type2, ushort vertex0, ushort vertex1, ushort vertex2)
 {
     this.type0   = type0;
     this.type1   = type1;
     this.type2   = type2;
     this.vertex0 = vertex0;
     this.vertex1 = vertex1;
     this.vertex2 = vertex2;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Create a Triangle object where all the vertex index types are
 /// refering to this objects vertices.
 /// </summary>
 /// <param name="vertex0">
 /// A ushort representing a vertex index.
 /// </param>
 /// <param name="vertex1">
 /// A ushort representing a vertex index.
 /// </param>
 /// <param name="vertex2">
 /// A ushort representing a vertex index.
 /// </param>
 public Triangle(ushort vertex0, ushort vertex1, ushort vertex2)
 {
     this.type0   = TriIndexType.Vertex;
     this.type1   = TriIndexType.Vertex;
     this.type2   = TriIndexType.Vertex;
     this.vertex0 = vertex0;
     this.vertex1 = vertex1;
     this.vertex2 = vertex2;
 }
Ejemplo n.º 6
0
 private int OptionIndex(TriIndexType type)
 {
     for (int k = 0; k < _options.Length; k++)
     {
         if (type == _options[k])
         {
             return(k);
         }
     }
     return(-1);
 }
Ejemplo n.º 7
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);
 }
Ejemplo n.º 8
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));
    }
Ejemplo n.º 9
0
 /// <summary>
 /// Creates and initializes a specified type of TriIndex,
 /// without encoding version.
 /// </summary>
 /// <param name="type">
 /// A TriIndexType variable that describes what kind of
 /// TriIndex this should be interpreted as.
 /// </param>
 /// <param name="axis_index">
 /// A byte variable whose value is stored directly, can be a part of an
 /// encoded vertex index or the index of an axi.
 /// </param>
 /// <param name="index">
 /// A byte variable whose value is stored directly, can be a part of an
 /// encoded vertex index or a socket index.
 /// </param>
 public TriIndex(TriIndexType type, byte axis_index, byte index)
 {
     this.type         = type;
     this.axi_index    = axis_index;
     this.socket_index = index;
 }