Ejemplo n.º 1
0
        public MyEdgeInfo(ref Vector3 pos, ref Vector3I edgeDirection, ref Vector3 normal0, ref Vector3 normal1, ref VRageMath.Color color, MyStringHash edgeModel)
        {
            MyEdgeOrientationInfo info = MyCubeGridDefinitions.EdgeOrientations[edgeDirection];

            this.PackedNormal0    = Base27Directions.GetDirection((Vector3)normal0);
            this.PackedNormal1    = Base27Directions.GetDirection((Vector3)normal1);
            this.m_packedColor    = color;
            this.EdgeType         = info.EdgeType;
            this.LocalOrthoMatrix = Vector4.PackOrthoMatrix(pos, info.Orientation.Forward, info.Orientation.Up);
            this.EdgeModel        = edgeModel;
        }
Ejemplo n.º 2
0
 public void Get(int index, out Color color, out int edgeModel, out Base27Directions.Direction normal0, out Base27Directions.Direction normal1)
 {
     fixed(uint *i = m_data)
     fixed(byte *d    = m_data2)
     fixed(int *edges = m_edgeModels)
     {
         color     = new Color(i[index]);
         normal0   = (Base27Directions.Direction)color.A;
         normal1   = (Base27Directions.Direction)d[index];
         edgeModel = edges[index];
     }
 }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
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;
        }
Ejemplo n.º 5
0
 public void Get(int index, out Color color, out MyStringHash edgeModel, out Base27Directions.Direction normal0, out Base27Directions.Direction normal1)
 {
     fixed(uint *i = m_data)
     fixed(byte *d    = m_data2)
     fixed(int *edges = m_edgeModels)
     {
         color     = new Color(i[index]);
         normal0   = (Base27Directions.Direction)color.A;
         normal1   = (Base27Directions.Direction)d[index];
         edgeModel = MyStringHash.TryGet(edges[index]);
         Debug.Assert(edges[index] == 0 || edgeModel != MyStringHash.NullOrEmpty);
     }
 }
Ejemplo n.º 6
0
            public bool Set(int index, Color value, int edgeModel, Base27Directions.Direction normal0, Base27Directions.Direction normal1)
            {
                fixed(uint *i = m_data)
                fixed(byte *d    = m_data2)
                fixed(int *edges = m_edgeModels)
                {
                    value.A = (byte)normal0;
                    bool result = i[index] == 0;

                    i[index]     = value.PackedValue;
                    d[index]     = (byte)normal1;
                    edges[index] = edgeModel;
                    return(result);
                }
            }
Ejemplo n.º 7
0
 public bool GetNormalInfo(int index, out Color color, out int edgeModel, out Base27Directions.Direction normal0, out Base27Directions.Direction normal1)
 {
     m_data.Get(index, out color, out edgeModel, out normal0, out normal1);
     color.A = 0;
     return(normal0 != 0);
 }
Ejemplo n.º 8
0
 public bool AddInstance(Vector3 blockPos, Color color, int edgeModel, Base27Directions.Direction normal0, Base27Directions.Direction normal1)
 {
     return(m_data.Set(GetIndex(ref blockPos), color, edgeModel, normal0, normal1));
 }
Ejemplo n.º 9
0
        public static MatrixD GetRotated(this MatrixD matrix, Base27Directions.Direction direction)
        {
            switch (direction)
            {
            case (Base27Directions.Direction.Forward | Base27Directions.Direction.Left):
                return(MatrixD.CreateWorld(matrix.Translation,
                                           Vector3D.Normalize(matrix.Forward + matrix.Left),
                                           Vector3D.Normalize(matrix.Up)));

            case (Base27Directions.Direction.Forward | Base27Directions.Direction.Right):
                return(MatrixD.CreateWorld(matrix.Translation,
                                           Vector3D.Normalize(matrix.Forward + matrix.Right),
                                           Vector3D.Normalize(matrix.Up)));

            case (Base27Directions.Direction.Forward | Base27Directions.Direction.Up):
                return(MatrixD.CreateWorld(matrix.Translation,
                                           Vector3D.Normalize(matrix.Forward + matrix.Up),
                                           Vector3D.Normalize(matrix.Left)));

            case (Base27Directions.Direction.Forward | Base27Directions.Direction.Down):
                return(MatrixD.CreateWorld(matrix.Translation,
                                           Vector3D.Normalize(matrix.Forward + matrix.Down),
                                           Vector3D.Normalize(matrix.Left)));

            case (Base27Directions.Direction.Forward | Base27Directions.Direction.Left | Base27Directions.Direction.Up):
                return(MatrixD.CreateWorld(matrix.Translation,
                                           Vector3D.Normalize(matrix.Forward + matrix.Left + matrix.Up),
                                           Vector3D.Normalize(matrix.Backward + matrix.Right + matrix.Up)));

            case (Base27Directions.Direction.Forward | Base27Directions.Direction.Left | Base27Directions.Direction.Down):
                return(MatrixD.CreateWorld(matrix.Translation,
                                           Vector3D.Normalize(matrix.Forward + matrix.Left + matrix.Down),
                                           Vector3D.Normalize(matrix.Forward + matrix.Left + matrix.Up)));

            case (Base27Directions.Direction.Forward | Base27Directions.Direction.Right | Base27Directions.Direction.Up):
                return(MatrixD.CreateWorld(matrix.Translation,
                                           Vector3D.Normalize(matrix.Forward + matrix.Right + matrix.Up),
                                           Vector3D.Normalize(matrix.Backward + matrix.Left + matrix.Up)));

            case (Base27Directions.Direction.Forward | Base27Directions.Direction.Right | Base27Directions.Direction.Down):
                return(MatrixD.CreateWorld(matrix.Translation,
                                           Vector3D.Normalize(matrix.Forward + matrix.Right + matrix.Down),
                                           Vector3D.Normalize(matrix.Forward + matrix.Right + matrix.Up)));

            case (Base27Directions.Direction.Backward):
                return(MatrixD.CreateWorld(matrix.Translation, matrix.Backward, matrix.Up));

            case (Base27Directions.Direction.Backward | Base27Directions.Direction.Left):
                return(MatrixD.CreateWorld(matrix.Translation,
                                           Vector3D.Normalize(matrix.Backward + matrix.Left),
                                           Vector3D.Normalize(matrix.Up)));

            case (Base27Directions.Direction.Backward | Base27Directions.Direction.Right):
                return(MatrixD.CreateWorld(matrix.Translation,
                                           Vector3D.Normalize(matrix.Backward + matrix.Right),
                                           Vector3D.Normalize(matrix.Up)));

            case (Base27Directions.Direction.Backward | Base27Directions.Direction.Up):
                return(MatrixD.CreateWorld(matrix.Translation,
                                           Vector3D.Normalize(matrix.Backward + matrix.Up),
                                           Vector3D.Normalize(matrix.Right)));

            case (Base27Directions.Direction.Backward | Base27Directions.Direction.Down):
                return(MatrixD.CreateWorld(matrix.Translation,
                                           Vector3D.Normalize(matrix.Backward + matrix.Down),
                                           Vector3D.Normalize(matrix.Right)));

            case (Base27Directions.Direction.Backward | Base27Directions.Direction.Left | Base27Directions.Direction.Up):
                return(MatrixD.CreateWorld(matrix.Translation,
                                           Vector3D.Normalize(matrix.Backward + matrix.Left + matrix.Up),
                                           Vector3D.Normalize(matrix.Forward + matrix.Right + matrix.Up)));

            case (Base27Directions.Direction.Backward | Base27Directions.Direction.Left | Base27Directions.Direction.Down):
                return(MatrixD.CreateWorld(matrix.Translation,
                                           Vector3D.Normalize(matrix.Backward + matrix.Left + matrix.Down),
                                           Vector3D.Normalize(matrix.Backward + matrix.Left + matrix.Up)));

            case (Base27Directions.Direction.Backward | Base27Directions.Direction.Right | Base27Directions.Direction.Up):
                return(MatrixD.CreateWorld(matrix.Translation,
                                           Vector3D.Normalize(matrix.Backward + matrix.Right + matrix.Up),
                                           Vector3D.Normalize(matrix.Forward + matrix.Left + matrix.Up)));

            case (Base27Directions.Direction.Backward | Base27Directions.Direction.Right | Base27Directions.Direction.Down):
                return(MatrixD.CreateWorld(matrix.Translation,
                                           Vector3D.Normalize(matrix.Backward + matrix.Right + matrix.Down),
                                           Vector3D.Normalize(matrix.Backward + matrix.Right + matrix.Up)));

            case (Base27Directions.Direction.Left):
                return(MatrixD.CreateWorld(matrix.Translation, matrix.Left, matrix.Up));

            case (Base27Directions.Direction.Left | Base27Directions.Direction.Up):
                return(MatrixD.CreateWorld(matrix.Translation,
                                           Vector3D.Normalize(matrix.Up + matrix.Left),
                                           Vector3D.Normalize(matrix.Forward)));

            case (Base27Directions.Direction.Left | Base27Directions.Direction.Down):
                return(MatrixD.CreateWorld(matrix.Translation,
                                           Vector3D.Normalize(matrix.Down + matrix.Left),
                                           Vector3D.Normalize(matrix.Forward)));

            case (Base27Directions.Direction.Right):
                return(MatrixD.CreateWorld(matrix.Translation, matrix.Right, matrix.Up));

            case (Base27Directions.Direction.Right | Base27Directions.Direction.Up):
                return(MatrixD.CreateWorld(matrix.Translation,
                                           Vector3D.Normalize(matrix.Up + matrix.Right),
                                           Vector3D.Normalize(matrix.Backward)));

            case (Base27Directions.Direction.Right | Base27Directions.Direction.Down):
                return(MatrixD.CreateWorld(matrix.Translation,
                                           Vector3D.Normalize(matrix.Down + matrix.Right),
                                           Vector3D.Normalize(matrix.Backward)));

            case (Base27Directions.Direction.Up):
                return(MatrixD.CreateWorld(matrix.Translation, matrix.Up, matrix.Backward));

            case (Base27Directions.Direction.Down):
                return(MatrixD.CreateWorld(matrix.Translation, matrix.Down, matrix.Forward));

            default:
                return(MatrixD.CreateWorld(matrix.Translation, matrix.Forward, matrix.Up));
            }
        }
Ejemplo n.º 10
0
            public unsafe void Get(int index, out Color color, out MyStringHash skinSubtypeId, out MyStringHash edgeModel, out Base27Directions.Direction normal0, out Base27Directions.Direction normal1)
            {
                uint *numPtr  = &this.m_data.FixedElementField;
                byte *numPtr2 = &this.m_data2.FixedElementField;
                int * numPtr3 = &this.m_edgeModels.FixedElementField;
                int * numPtr4 = &this.m_skinSubtypes.FixedElementField;

                color         = new Color(numPtr[index]);
                normal0       = (Base27Directions.Direction)color.A;
                normal1       = (Base27Directions.Direction)numPtr2[index];
                edgeModel     = MyStringHash.TryGet(numPtr3[index]);
                skinSubtypeId = MyStringHash.TryGet(numPtr4[index]);
                fixed(int *numRef4 = null)
                {
                    fixed(int *numRef3 = null)
                    {
                        fixed(byte *numRef2 = null)
                        {
                            fixed(uint *numRef = null)
                            {
                                return;
                            }
                        }
                    }
                }
            }
Ejemplo n.º 11
0
 public bool GetNormalInfo(int index, out Color color, out MyStringHash skinSubtypeId, out MyStringHash edgeModel, out Base27Directions.Direction normal0, out Base27Directions.Direction normal1)
 {
     this.m_data.Get(index, out color, out skinSubtypeId, out edgeModel, out normal0, out normal1);
     color.A = 0;
     return(((int)normal0) != 0);
 }
Ejemplo n.º 12
0
 public bool AddInstance(Vector3 blockPos, Color color, MyStringHash skinSubtype, MyStringHash edgeModel, Base27Directions.Direction normal0, Base27Directions.Direction normal1) =>
 this.m_data.Set(this.GetIndex(ref blockPos), color, skinSubtype, edgeModel, normal0, normal1);
Ejemplo n.º 13
0
            public unsafe bool Set(int index, Color value, MyStringHash skinSubtype, MyStringHash edgeModel, Base27Directions.Direction normal0, Base27Directions.Direction normal1)
            {
                uint *numPtr  = &this.m_data.FixedElementField;
                byte *numPtr2 = &this.m_data2.FixedElementField;
                int * numPtr3 = &this.m_skinSubtypes.FixedElementField;

                value.A = (byte)normal0;
                uint packedValue = value.PackedValue;
                bool flag        = false;

                if (numPtr[index] != packedValue)
                {
                    flag          = true;
                    numPtr[index] = packedValue;
                }
                numPtr2[index] = (byte)normal1;
                &this.m_edgeModels.FixedElementField[index] = (int)edgeModel;
                if (numPtr3[index] != ((int)skinSubtype))
                {
                    flag           = true;
                    numPtr3[index] = (int)skinSubtype;
                }
                return(flag);
            }