Esempio n. 1
0
        /// <summary>
        /// Carga de contenido gráfico
        /// </summary>
        protected override void LoadContent()
        {
            base.LoadContent();

            // Información del componente
            BuildingComponentInfo componentInfo = BuildingComponentInfo.Load(this.ComponentsDirectory + this.ComponentInfoName);

            // Modelo
            this.m_ModelName = componentInfo.Model;

            if (!g_ModelDictionary.ContainsKey(componentInfo.Model))
            {
                Model         model      = Content.Load <Model>(this.ComponentsDirectory + this.m_ModelName);
                PrimitiveInfo primitives = model.Tag as PrimitiveInfo;

                GeometryInfo geometry = new GeometryInfo()
                {
                    Model      = model,
                    Primitives = primitives,
                };

                g_ModelDictionary.Add(this.m_ModelName, geometry);
            }

            CollisionBox obb = new CollisionBox(this.TriangleInfo.AABB, 1000000f);

            this.m_CollisionPrimitive = obb;
            this.m_Offset             = Matrix.CreateTranslation(new Vector3(0f, -obb.HalfSize.Y, 0f));

            // Controles de animación
            this.m_AnimationController.AddRange(Animation.CreateAnimationList(this.Model, componentInfo.AnimationControlers));

            // Transformaciones iniciales
            this.m_BoneTransforms = new Matrix[Model.Bones.Count];
        }
Esempio n. 2
0
 private void CurrentGeoChanged(GeometryInfo info)
 {
     if (Mode == SelectionMode.Current)
     {
         UpdateFromCurrent();
     }
 }
Esempio n. 3
0
 public GeoPoint(double Longitude, double Latitude, T properties)
 {
     Type     = "Feature";
     Geometry = new GeometryInfo {
         Type = "Point", Coordinates = new double[] { Longitude, Latitude }
     };
     this.properties = properties;
 }
Esempio n. 4
0
 public DiskInfo(VolumeData data)
 {
     m_Data = data;
     if (!IsRemovableMedia || IsMediaPresent)
     {
         Geometry = new GeometryInfo(data);
     }
     if (m_Data.DeviceQuery != null)
     {
         Device = new DeviceInfo(data);
     }
 }
            /// <summary>
            /// Adds a geometry name and index pair to the list, if an element with a matching index does not already exist
            /// </summary>
            /// <param name="name">The geometry name</param>
            /// <param name="index">The geometry index</param>
            public void AddGeometry(string name, int index)
            {
                if (GeometryExists(index))
                {
                    return;
                }

                GeometryInfo geometry = new GeometryInfo();

                geometry.Name  = name;
                geometry.Index = index;

                geometries.Add(geometry);
            }
Esempio n. 6
0
        /// <summary>
        /// Carga de contenido gráfico
        /// </summary>
        protected override void LoadContent()
        {
            base.LoadContent();

            // Información del componente
            VehicleComponentInfo componentInfo = VehicleComponentInfo.Load(Path.Combine(this.AssetsFolder, this.ComponentInfoName));

            // Modelo
            this.m_ModelName = componentInfo.Model;

            if (!g_ModelDictionary.ContainsKey(componentInfo.Model))
            {
                Model         model      = Content.Load <Model>(Path.Combine(this.AssetsFolder, this.m_ModelName));
                PrimitiveInfo primitives = model.Tag as PrimitiveInfo;

                GeometryInfo geometry = new GeometryInfo()
                {
                    Model      = model,
                    Primitives = primitives,
                };

                g_ModelDictionary.Add(this.m_ModelName, geometry);
            }

            CollisionBox box = new CollisionBox(this.TriangleInfo.AABB, 1000f);

            this.m_CollisionPrimitive = box;
            this.m_Offset             = Matrix.CreateTranslation(new Vector3(0f, -box.HalfSize.Y, 0f));

            // Integridad
            this.BaseHull = this.Hull = componentInfo.Hull;
            // Blindaje
            this.BaseArmor = this.Armor = componentInfo.Armor;

            // Altura máxima de vuelo
            this.Engine.InitialMaxFlightHeight = componentInfo.MaxFlightHeight;
            // Altura mínima de vuelo
            this.Engine.InitialMinFlightHeight = componentInfo.MinFlightHeight;

            // Velocidad máxima que puede alcanzar el vehículo hacia delante
            this.Engine.MaxForwardVelocity = componentInfo.MaxForwardVelocity;
            // Velocidad máxima que puede alcanzar el vehículo marcha atrás
            this.Engine.MaxBackwardVelocity = componentInfo.MaxBackwardVelocity;
            // Modificador de aceleración
            this.Engine.AccelerationModifier = componentInfo.AccelerationModifier;
            // Modificador de frenado
            this.Engine.BrakeModifier = componentInfo.BrakeModifier;
            // Velocidad angular
            this.Engine.AngularVelocityModifier = MathHelper.ToRadians(componentInfo.AngularVelocityModifier);
            // Vehículo volador
            this.Engine.Skimmer = componentInfo.Skimmer;
            // Altura máxima
            this.Engine.MaxFlightHeight = componentInfo.MaxFlightHeight;
            // Altura mínima
            this.Engine.MinFlightHeight = componentInfo.MinFlightHeight;
            // Rotación ascendente del morro
            this.Engine.AscendingAngle = MathHelper.ToRadians(componentInfo.AscendingAngle);
            // Rotación descendente del morro
            this.Engine.DescendingAngle = MathHelper.ToRadians(componentInfo.DescendingAngle);
            // Controles de animación
            this.m_AnimationController.AddRange(Animation.Animation.CreateAnimationList(this.Model, componentInfo.AnimationControlers));
            // Posiciones
            this.m_PlayerControlList.AddRange(Animation.PlayerPosition.CreatePlayerPositionList(this.Model, componentInfo.PlayerPositions));
            // Armas
            this.m_WeapontList.AddRange(Weapon.CreateWeaponList(this.Model, componentInfo.Weapons));
            // Emisores de partículas
            this.m_ParticleEmitterList.AddRange(ParticleEmitter.CreateParticleEmitterList(this.Model, componentInfo.ParticleEmitters));

            // Transformaciones iniciales
            this.m_BoneTransforms = new Matrix[this.Model.Bones.Count];
        }
Esempio n. 7
0
        public SceneGeometryInfo Load( string fileName, params string[] additionalFiles ) {
            var result = new SceneGeometryInfo();
            var objs = new List<GeometryInfo>();
            string lastCommand = "f";

            FloatStore vb = null;
            FloatStore vt = null;
            FloatStore vn = null;

            IntStore ib = null;

            IntStore tib = null;
            IntStore nib = null;
            int oCount = 0;
            var buffer = new Queue<string>();
            using( var reader = new StreamReader(fileName) ) {
                while( !reader.EndOfStream ) {
                    var s = reader.ReadLine();
                    if( String.IsNullOrEmpty(s) )
                        continue;
                    buffer.Enqueue(s);
                }
            }

            while( buffer.Count > 0 ) {
                string line = buffer.Dequeue();

                if( string.IsNullOrEmpty(line) )
                    continue;
                if( line.StartsWith("#") )
                    continue;


                //try
                //{
                var tag = line.Contains(" ") ? line.Substring(0, line.IndexOf(" ")).Trim() : line.Trim();
                switch( tag ) {
                    case "vt":
                        if( vt == null ) {
                            vt = objs[oCount - 1].TextureData;
                        }
                        objs[oCount - 1].UseTextures = true;
                        vt.AddRange(ObjHandler.Process_VT(line));
                        break;
                    case "vn":

                        if( vn == null ) {
                            vn = objs[oCount - 1].NormalData;
                        }
                        objs[oCount - 1].UseNormals = true;
                        vn.AddRange(ObjHandler.Process_VN(line));
                        break;
                    case "v":
                        if( lastCommand.Equals("f") ) {
                            var newObj = new GeometryInfo();
                            objs.Add(newObj);
                            //vb = newObj.VertexBuffer;
                            vn = null;
                            ib = null;
                            tib = null;
                            nib = null;
                            oCount++;
                        }
                        if( vb == null ) {
                            vb = objs[oCount - 1].VertexData;
                        }
                        vb.AddRange(ObjHandler.Process_V(line));
                        break;

                    case "f":
                        if( ib == null ) {
                            ib = objs[oCount - 1].IndexData;
                        }
                        int[] tibs, nibs;
                        var ibValues = ObjHandler.Process_F(line, out nibs, out tibs);
                        bool TexInd = false;
                        bool NormInd = false;
                        ib.AddRange(ibValues);
                        if( objs[oCount - 1].UseTextures && objs[oCount - 1].UseNormals ) {
                            NormInd = true;
                            TexInd = true;
                        }
                        else if( objs[oCount - 1].UseTextures && !objs[oCount - 1].UseNormals ) {
                            TexInd = true;
                            tibs = nibs;
                        }
                        else
                            if( !objs[oCount - 1].UseTextures && objs[oCount - 1].UseNormals ) {
                                NormInd = true;
                            }
                        if( TexInd ) {
                            if( tib == null ) {
                                objs[oCount - 1].TextureIndexData = new IntStore();
                                tib = objs[oCount - 1].TextureIndexData;
                            }
                            if( tibs != null ) {
                                tib.AddRange(tibs);
                            }
                            else {
                                tib.AddRange(nibs);
                            }
                        }

                        if( NormInd ) {
                            if( nib == null ) {
                                objs[oCount - 1].NormalIndexData = new IntStore();
                                nib = objs[oCount - 1].NormalIndexData;
                            }
                            nib.AddRange(nibs);
                        }
                        break;

                    case "g":
                        if( lastCommand.Equals("f") ) {
                            var newObj = new GeometryInfo();
                            objs.Add(newObj);
                            //vb = null;
                            vn = null;
                            ib = null;
                            tib = null;
                            nib = null;
                            oCount++;
                        }
                        string name = string.Empty;
                        ObjHandler.Process_G(line, out name);
                        objs[oCount - 1].Name = name;
                        break;
                    case "usemtl":
                        string mtl = string.Empty;
                        ObjHandler.Process_Mtl(line, out mtl);
                        objs[oCount - 1].MaterialName = mtl.ToLowerInvariant();
                        break;
                    default:
                        continue;


                }
                lastCommand = tag;
                //}
                //catch (Exception ex)
                //{
                //    throw ex;
                //    //continue;

                //}
            }


            result.Vertices = vb.TodVectorList().ToArray();
            result.TexCoords = vt.TodVectorList().ToArray();
            result.Normals = vn.TodVectorList().ToArray();


            objs.ForEach(ob => {
                ob.IndexData.Iterator(Math.Abs);
                if( ob.TextureIndexData != null )
                    ob.TextureIndexData.Iterator(Math.Abs);
                if( ob.NormalIndexData != null )
                    ob.NormalIndexData.Iterator(Math.Abs);

                ob.Name = String.IsNullOrEmpty(ob.Name) ? Guid.NewGuid().ToString() : ob.Name;
            });


            return result;
        }
Esempio n. 8
0
			/// <summary>
			/// Adds a geometry name and index pair to the list, if an element with a matching index does not already exist
			/// </summary>
			/// <param name="name">The geometry name</param>
			/// <param name="index">The geometry index</param>
			public void AddGeometry(string name, int index)
			{
				if (GeometryExists(index))
					return;

				GeometryInfo geometry = new GeometryInfo();
				geometry.Name = name;
				geometry.Index = index;

				geometries.Add(geometry);
			}