public DrawableLevelObjectInstance(LevelObject lo, LevelObjectData data, ServiceManager services)
 {
     m_lo = lo;
     m_services = services;
     Init(data);
 }
        private void Init(LevelObjectData data)
        {
            /* Create the link between the instance and it's type */
            m_lot = data.GetObjectTypeByGuid(m_lo.TypeId.ToString());

            if (m_lot == null)
            {
                /* ERROR: Could not find the type in the data definition */
                System.Diagnostics.Debug.Assert(false);
                return;
            }

            if (m_lot.ModelFileName.Length > 0)
            {
                Model model = null;
                data.FetchModel(m_lot.ModelFileName, m_services, out model);

                System.Diagnostics.Debug.Assert(model != null);
                m_model = model;

                List<Effect> list = new List<Effect>();
                foreach (ModelMesh mesh in m_model.Meshes)
                {
                    m_sphereBounds.Center += mesh.BoundingSphere.Center;
                    m_sphereBounds.Radius = Math.Max(m_sphereBounds.Radius, mesh.BoundingSphere.Radius);

                    foreach (Effect effect in mesh.Effects)
                    {
                        list.Add(effect);
                    }
                }

                m_sphereBounds.Center /= m_model.Meshes.Count;

                m_effects = new ReadOnlyCollection<Effect>(list);
            }
        }
Пример #3
0
        public void ShowObjectType(LevelObjectType type, LevelObjectData data)
        {
            DrawableLevelObjectType drawLot = new DrawableLevelObjectType(type, data, Services);

            ChangeViewMode(ViewMode.eTypeViewer);
            ResetView();
            m_scene.Add(type.Name, drawLot);
        }
Пример #4
0
 public void AddObjectInstanceToScene(LevelObject lo, LevelObjectData data)
 {
     DrawableLevelObjectInstance drawLo = new DrawableLevelObjectInstance(lo, data, Services);
     m_scene.Add(lo.Name, drawLo);
 }
Пример #5
0
 public void Init(LevelObjectData data, IServiceProvider deviceService)
 {
     m_data = data;
     m_deviceService = deviceService;
 }