Esempio n. 1
0
 public bool verifyProperty(Model model, Tuple <string, string> property, LOD sourceLod)
 {
     if (string.IsNullOrWhiteSpace(property.Item2))
     {
         throw new PropertyException(property.Item1, "Property value is empty.");
     }
     return(true);
 }
Esempio n. 2
0
        public bool verifyProperty(Model model, Tuple <string, string> property, LOD sourceLod)
        {
            var isNumeric = double.TryParse(property.Item2, out double n);

            if (!isNumeric)
            {
                throw new PropertyException(property.Item1, "Property is not a number.");
            }
            return(true);
        }
Esempio n. 3
0
 public bool verifyProperty(Model model, Tuple <string, string> property, LOD sourceLod)
 {
     if ((float)sourceLod.resolution < 901)
     {
         return(true);
     }
     else
     {
         throw new PropertyException(property.Item1, "Property is not in Resolution LOD");
     }
     //#TODO log name of which lod it was found on.
 }
Esempio n. 4
0
 public bool verifyProperty(Model model, Tuple <string, string> property, LOD sourceLod)
 {
     if (sourceLod.resolution == 1e13f) //#TODO if there is no geo lod, check that it's in the first lod.
     {
         return(true);
     }
     else
     {
         if (
             !model.lods.ContainsKey(1e13f) && //No geo lod. Check if property is in first lod.
             model.lods.First().Value != sourceLod    //Not on first lod! Error.
             )
         {
             throw new PropertyException(property.Item1, "Property is not in Geometry LOD");
         }
         return(true); //No geo lod, but property is on first lod. All fine.
     }
 }
Esempio n. 5
0
        public bool verifyProperty(Model model, Tuple <string, string> property, LOD sourceLod)
        {
            if (property.Item2 == "0" || property.Item2 == "1")
            {
                return(true);
            }

            var isNumeric = float.TryParse(property.Item2, out float n);

            if (!isNumeric)
            {
                throw new PropertyException(property.Item1, "Property is not a boolean. Only 0/1 values are allowed");
            }

            //It's still a number, but outside of the valid range
            throw new PropertyException(property.Item1, "Property is outside of range for boolean. Only 0/1 values are allowed", false);

            //#TODO suggest quick fix if it's yes/no or true/false
        }
Esempio n. 6
0
        private void loadFromMLOD(BinaryReaderEx reader)
        {
            reader.ReadUInt32();
            numLods = reader.ReadUInt32();
            for (int i = 0; i < numLods; i++)
            {
                LOD x          = new LOD();
                var resolution = x.loadFromMLOD(reader);
                x.resolution = resolution;

                if (lods.ContainsKey(x.resolution))
                {
                    x.propertyExceptions.Add(new PropertyException("<Model Loader>", "Duplicate LOD. This lod is " + x.resolution.ToString()));
                    lods.Add(-resolution, x);
                }
                else
                {
                    lods.Add(resolution, x);
                }
            }
        }
Esempio n. 7
0
 private void SelectionChanged(object sender, RoutedPropertyChangedEventArgs <Object> e)
 {
     currentLod = e.NewValue as LOD;
     OnPropertyChanged("currentLod");
 }
Esempio n. 8
0
        private void loadFromODOL(BinaryReaderEx reader)
        {
            var version = reader.ReadUInt32();//version

            if (version < 72)
            {
                //#TODO
                return;
            }



            reader.ReadUInt32();
            var muz = reader.ReadAsciiz();

            numLods = reader.ReadUInt32();
            float[] lodResolutions = new float[numLods];
            for (int i = 0; i < numLods; i++)
            {
                lodResolutions[i] = reader.ReadSingle();
            }



            reader.BaseStream.Seek(8 + 8 + 8 + 4 * 3 + 4 + 4 + 4 + 4 * 3 + 4 * 3
                                                       //lod dens coef
                                   + 4 + 4 + 4 * 3 * 5 //bb boxes
                                   + 4 * 9             //matrix
                                   + 4
                                   + 1                 //only if v>=73
                                   + 4 * 6
                                   + 1 + 4 + 1 + 4 + 1,
                                   SeekOrigin.Current
                                   );
            var skeletonName = reader.ReadAsciiz();


            if (skeletonName.Length != 0) //skeleton
            {
                reader.ReadByte();
                var numBones = reader.ReadUInt32();

                for (int i = 0; i < numBones; i++)
                {
                    while (reader.ReadByte() != 0)
                    {
                        ;                            //skip name
                    }
                    while (reader.ReadByte() != 0)
                    {
                        ;                            //skip name
                    }
                }

                reader.ReadByte();
            }

            reader.ReadByte();
            var massSize = reader.ReadUInt32();

            if (massSize != 0)
            {
                throw new NotImplementedException();
            }

            reader.BaseStream.Seek(16, SeekOrigin.Current);
            reader.BaseStream.Seek(4, SeekOrigin.Current); //#TODO only if >72

            reader.BaseStream.Seek(14
                                   + 4 + 1, SeekOrigin.Current); //#TODO only if >72

            var name1 = reader.ReadAsciiz();
            var name2 = reader.ReadAsciiz();

            reader.ReadByte();
            var numUnused = reader.ReadUInt32();

            if (numUnused != 0)
            {
                throw new NotImplementedException();
            }

            reader.BaseStream.Seek(12 * numLods, SeekOrigin.Current);

            if (reader.ReadByte() != 0)
            {
                skipAnimations(reader);
            }

            uint[] lodOffs = new uint[numLods];

            for (int i = 0; i < numLods; i++)
            {
                lodOffs[i] = reader.ReadUInt32();
            }

            reader.BaseStream.Seek(numLods, SeekOrigin.Current);

            for (int i = 0; i < numLods; i++)
            {
                reader.BaseStream.Seek(lodOffs[i], SeekOrigin.Begin);
                LOD x = new LOD();
                x.loadFromODOL(reader, Math.Abs(lodResolutions[i] - 1e15f) < 0.1);
                x.resolution = lodResolutions[i];

                if (lods.ContainsKey(x.resolution))
                {
                    x.propertyExceptions.Add(new PropertyException("<Model Loader>", "Duplicate LOD. This lod is " + x.resolution.ToString()));
                    lods.Add(-lodResolutions[i], x);
                }
                else
                {
                    lods.Add(lodResolutions[i], x);
                }
            }
        }