예제 #1
0
        public MyEdgeInfo(ref Vector3 pos, ref Vector3I edgeDirection, ref Vector3 normal0, ref Vector3 normal1, ref Color color, MyStringHash edgeModel)
        {
            var info = MyCubeGridDefinitions.EdgeOrientations[edgeDirection];
            Debug.Assert(info.EdgeType != MyCubeEdgeType.Hidden, "Hidden edge types are now allowed");

            PackedNormal0 = Base27Directions.GetDirection(normal0);
            PackedNormal1 = Base27Directions.GetDirection(normal1);
            m_packedColor = color;
            EdgeType = info.EdgeType;
            LocalOrthoMatrix = Vector4.PackOrthoMatrix(pos, info.Orientation.Forward, info.Orientation.Up);
            EdgeModel = edgeModel;
        }
예제 #2
0
        public MyEdgeInfo(ref Vector3 pos, ref Vector3I edgeDirection, ref Vector3 normal0, ref Vector3 normal1, ref Color color, MyStringId edgeModel)
        {
            var info = MyCubeGridDefinitions.EdgeOrientations[edgeDirection];

            Debug.Assert(info.EdgeType != MyCubeEdgeType.Hidden, "Hidden edge types are now allowed");

            PackedNormal0    = Base27Directions.GetDirection(normal0);
            PackedNormal1    = Base27Directions.GetDirection(normal1);
            m_packedColor    = color;
            EdgeType         = info.EdgeType;
            LocalOrthoMatrix = Vector4.PackOrthoMatrix(pos, info.Orientation.Forward, info.Orientation.Up);
            EdgeModel        = edgeModel;
        }
예제 #3
0
 public MyEdgeOrientationInfo(Matrix localMatrix, MyCubeEdgeType edgeType)
 {
     this.Orientation = localMatrix;
     this.EdgeType    = edgeType;
 }
예제 #4
0
        private bool IsEdgeVisible(MyFourEdgeInfo edgeInfo, out int modelId)
        {
            int[] numArray;
            modelId = 0;
            m_edgesToCompare.Clear();
            if (edgeInfo.Full)
            {
                return(false);
            }
            for (int i = 0; i < 4; i++)
            {
                Color        color;
                MyStringHash hash2;
                MyStringHash hash3;
                Base27Directions.Direction direction;
                Base27Directions.Direction direction2;
                if (edgeInfo.GetNormalInfo(i, out color, out hash3, out hash2, out direction, out direction2))
                {
                    EdgeInfoNormal item = new EdgeInfoNormal {
                        Normal        = Base27Directions.GetVector(direction),
                        Color         = color,
                        SkinSubtypeId = hash3,
                        EdgeModel     = hash2
                    };
                    m_edgesToCompare.Add(item);
                    item = new EdgeInfoNormal {
                        Normal        = Base27Directions.GetVector(direction2),
                        Color         = color,
                        SkinSubtypeId = hash3,
                        EdgeModel     = hash2
                    };
                    m_edgesToCompare.Add(item);
                }
            }
            if (m_edgesToCompare.Count == 0)
            {
                return(false);
            }
            bool         flag      = m_edgesToCompare.Count == 4;
            MyStringHash edgeModel = m_edgesToCompare[0].EdgeModel;
            int          index     = 0;

            while (index < m_edgesToCompare.Count)
            {
                int num6 = index + 1;
                while (true)
                {
                    if (num6 < m_edgesToCompare.Count)
                    {
                        if (!MyUtils.IsZero(m_edgesToCompare[index].Normal + m_edgesToCompare[num6].Normal, 0.1f))
                        {
                            num6++;
                            continue;
                        }
                        m_edgesToCompare.RemoveAt(num6);
                        m_edgesToCompare.RemoveAt(index);
                        index--;
                    }
                    index++;
                    break;
                }
            }
            if (m_edgesToCompare.Count == 1)
            {
                return(false);
            }
            bool flag2 = false;
            bool flag3 = false;
            bool flag4 = false;

            if (m_edgesToCompare.Count > 0)
            {
                Color        color         = m_edgesToCompare[0].Color;
                MyStringHash skinSubtypeId = m_edgesToCompare[0].SkinSubtypeId;
                edgeModel = m_edgesToCompare[0].EdgeModel;
                for (int j = 1; j < m_edgesToCompare.Count; j++)
                {
                    EdgeInfoNormal normal2 = m_edgesToCompare[j];
                    flag2 |= normal2.Color != color;
                    flag4 |= normal2.SkinSubtypeId != skinSubtypeId;
                    flag3 |= edgeModel != normal2.EdgeModel;
                    if ((flag2 | flag3) | flag4)
                    {
                        break;
                    }
                }
            }
            if (!((m_edgesToCompare.Count != 1) ? (!((flag2 | flag3) | flag4) ? ((m_edgesToCompare.Count <= 2) ? ((m_edgesToCompare.Count != 0) ? (Math.Abs(Vector3.Dot(m_edgesToCompare[0].Normal, m_edgesToCompare[1].Normal)) <= 0.85f) : flag) : true) : true) : false))
            {
                return(false);
            }
            int edgeTypeCount = m_edgeTypeCount;

            if (!m_edgeModelIdCache.TryGetValue(edgeModel, out numArray))
            {
                MyDefinitionId    id = new MyDefinitionId(m_edgeDefinitionType, edgeModel);
                MyEdgesDefinition edgesDefinition = MyDefinitionManager.Static.GetEdgesDefinition(id);
                MyEdgesModelSet   small           = edgesDefinition.Small;
                MyEdgesModelSet   large           = edgesDefinition.Large;
                numArray = new int[m_edgeTypeCount * 2];
                MyCubeEdgeType[] values = MyEnum <MyCubeEdgeType> .Values;
                int num8 = 0;
                while (true)
                {
                    int num9;
                    int num10;
                    if (num8 >= values.Length)
                    {
                        m_edgeModelIdCache.Add(edgeModel, numArray);
                        break;
                    }
                    MyCubeEdgeType type = values[num8];
                    switch (type)
                    {
                    case MyCubeEdgeType.Vertical:
                        num9  = MyModel.GetId(small.Vertical);
                        num10 = MyModel.GetId(large.Vertical);
                        break;

                    case MyCubeEdgeType.Vertical_Diagonal:
                        num9  = MyModel.GetId(small.VerticalDiagonal);
                        num10 = MyModel.GetId(large.VerticalDiagonal);
                        break;

                    case MyCubeEdgeType.Horizontal:
                        num9  = MyModel.GetId(small.Horisontal);
                        num10 = MyModel.GetId(large.Horisontal);
                        break;

                    case MyCubeEdgeType.Horizontal_Diagonal:
                        num9  = MyModel.GetId(small.HorisontalDiagonal);
                        num10 = MyModel.GetId(large.HorisontalDiagonal);
                        break;

                    case MyCubeEdgeType.Hidden:
                        num9  = 0;
                        num10 = 0;
                        break;

                    default:
                        throw new Exception("Unhandled edge type");
                    }
                    int num11 = (int)type;
                    numArray[num11] = num9;
                    numArray[num11 + edgeTypeCount] = num10;
                    num8++;
                }
            }
            int edgeType = (int)edgeInfo.EdgeType;

            modelId = numArray[((this.m_gridRenderComponent.GridSizeEnum == MyCubeSize.Large) ? edgeTypeCount : 0) + edgeType];
            return(true);
        }
예제 #5
0
 public MyFourEdgeInfo(Vector4 localOrthoMatrix, MyCubeEdgeType edgeType)
 {
     m_data.LocalOrthoMatrix = localOrthoMatrix;
     m_data.EdgeType         = edgeType;
 }
 public MyEdgeOrientationInfo(Matrix localMatrix, MyCubeEdgeType edgeType)
 {
     Orientation = localMatrix;
     EdgeType = edgeType;
 }
 public MyFourEdgeInfo(Vector4 localOrthoMatrix, MyCubeEdgeType edgeType)
 {
     m_data.LocalOrthoMatrix = localOrthoMatrix;
     m_data.EdgeType = edgeType;
 }