Class to hold a 4x4 Matrix
Exemplo n.º 1
0
        public unsafe static List <IDictionary> CreateXModelDictionary(ProcessReader reader, long address, int count, List <IDictionary> MapEntities)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
            // Read buffer
            var byteBuffer = reader.ReadBytes(address, count * Marshal.SizeOf <GfxStaticModel>());
            // Loop number of models we have
            List <IDictionary> MapModels = new List <IDictionary>(count);

            for (int i = 0; i < count; i++)
            {
                Dictionary <string, string> ModelData = new Dictionary <string, string>();
                List <double> Position = new List <double>();
                List <double> angles   = new List <double>();
                // Read Struct
                var staticModel = ByteUtil.BytesToStruct <GfxStaticModel>(byteBuffer, i * Marshal.SizeOf <GfxStaticModel>());
                // Model Name
                var modelName = reader.ReadNullTerminatedString(reader.ReadInt32(staticModel.ModelPointer));

                var matrix = new Rotation.Matrix();
                // Copy X Values
                matrix.Values[0] = staticModel.Matrix[0];
                matrix.Values[1] = staticModel.Matrix[1];
                matrix.Values[2] = staticModel.Matrix[2];
                // Copy Y Values
                matrix.Values[4] = staticModel.Matrix[3];
                matrix.Values[5] = staticModel.Matrix[4];
                matrix.Values[6] = staticModel.Matrix[5];
                // Copy Z Values
                matrix.Values[8]  = staticModel.Matrix[6];
                matrix.Values[9]  = staticModel.Matrix[7];
                matrix.Values[10] = staticModel.Matrix[8];
                // Convert to Euler
                var euler = matrix.ToEuler();
                // Add it
                if (string.IsNullOrEmpty(modelName) == true || modelName.Contains("?") == true || modelName.Contains("'") == true || modelName.Contains("\\") == true || modelName.Contains("fx") == true || modelName.Contains("viewmodel") == true || staticModel.ModelScale < 0.001 || staticModel.ModelScale > 10)
                {
                }
                else
                {
                    ModelData.Add("Name", CleanInput(modelName));
                    ModelData.Add("PosX", string.Format("{0:0.0000}", staticModel.X));
                    ModelData.Add("PosY", string.Format("{0:0.0000}", staticModel.Y));
                    ModelData.Add("PosZ", string.Format("{0:0.0000}", staticModel.Z));
                    ModelData.Add("RotX", string.Format("{0:0.0000}", (float)Rotation.ToDegrees(euler).X).ToString(CultureInfo.InvariantCulture));
                    ModelData.Add("RotY", string.Format("{0:0.0000}", (float)Rotation.ToDegrees(euler).Y).ToString(CultureInfo.InvariantCulture));
                    ModelData.Add("RotZ", string.Format("{0:0.0000}", (float)Rotation.ToDegrees(euler).Z).ToString(CultureInfo.InvariantCulture));
                    ModelData.Add("Scale", string.Format("{0:0.0000}", staticModel.ModelScale).ToString(CultureInfo.InvariantCulture));
                    MapModels.Add(new Dictionary <string, string>(ModelData));
                }
            }
            foreach (IDictionary entity in MapEntities)
            {
                MapModels.Add(entity);
            }


            // Done
            return(MapModels);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Reads Static Models
        /// </summary>
        public unsafe static List <IWMap.Entity> ReadStaticModels(ProcessReader reader, long address, int count)
        {
            // Resulting Entities
            List <IWMap.Entity> entities = new List <IWMap.Entity>(count);
            // Read buffer
            var byteBuffer = reader.ReadBytes(address, count * Marshal.SizeOf <GfxStaticModel>());

            // Loop number of models we have
            for (int i = 0; i < count; i++)
            {
                // Read Struct
                var staticModel = ByteUtil.BytesToStruct <GfxStaticModel>(byteBuffer, i * Marshal.SizeOf <GfxStaticModel>());
                // Model Name
                var modelName = reader.ReadNullTerminatedString(reader.ReadInt64(staticModel.ModelPointer));
                // New Matrix
                var matrix = new Rotation.Matrix();
                // Copy X Values
                matrix.Values[0] = staticModel.Matrix[0];
                matrix.Values[1] = staticModel.Matrix[1];
                matrix.Values[2] = staticModel.Matrix[2];
                // Copy Y Values
                matrix.Values[4] = staticModel.Matrix[3];
                matrix.Values[5] = staticModel.Matrix[4];
                matrix.Values[6] = staticModel.Matrix[5];
                // Copy Z Values
                matrix.Values[8]  = staticModel.Matrix[6];
                matrix.Values[9]  = staticModel.Matrix[7];
                matrix.Values[10] = staticModel.Matrix[8];
                // Convert to Euler
                var euler = matrix.ToEuler();
                // Add it
                if (modelName.Contains("foliage"))
                {
                }
                else
                {
                    entities.Add(IWMap.Entity.CreateMiscModel(modelName, new Vector3(staticModel.X, staticModel.Y, staticModel.Z), Rotation.ToDegrees(euler), staticModel.ModelScale));
                }
            }



            // Done
            return(entities);
        }
Exemplo n.º 3
0
        ///TODO: Fix this crap
        public static unsafe List <IWMap.Entity> ReadStaticModels(uint address, int count)
        {
            // Resulting Entities
            var entities = new List <IWMap.Entity>(count);
            // Read buffer
            var byteBuffer = console.GetMemory(address, (uint)(count * Marshal.SizeOf <GfxStaticModel>()));

            // Loop number of models we have
            for (var i = 0; i < count; i++)
            {
                // Read Struct
                var staticModel = ByteUtil.BytesToStruct <GfxStaticModel>(byteBuffer, i * Marshal.SizeOf <GfxStaticModel>());
                // Model Name
                var modelName = console.ReadString((uint)staticModel.ModelPointer);//reader.ReadNullTerminatedString(reader.ReadInt32(staticModel.ModelPointer));
                // New Matrix
                var matrix = new Rotation.Matrix
                {
                    Values =
                    {
                        [0]  = staticModel.Matrix[0],
                        [1]  = staticModel.Matrix[1],
                        [2]  = staticModel.Matrix[2],
                        [4]  = staticModel.Matrix[3],
                        [5]  = staticModel.Matrix[4],
                        [6]  = staticModel.Matrix[5],
                        [8]  = staticModel.Matrix[6],
                        [9]  = staticModel.Matrix[7],
                        [10] = staticModel.Matrix[8]
                    }
                };
                // Copy X Values
                // Copy Y Values
                // Copy Z Values
                // Convert to Euler
                var euler = matrix.ToEuler();
                // Add it
                entities.Add(IWMap.Entity.CreateMiscModel(modelName, new Vector3(staticModel.X, staticModel.Y, staticModel.Z), Rotation.ToDegrees(euler), staticModel.ModelScale));
            }
            // Done
            return(entities);
        }