/// <summary> /// Mod_LoadBrushModel /// </summary> public void LoadBrushModel(BrushModelData mod, byte[] buffer) { mod.Load(mod.Name, buffer, (tx) => { if (tx.name != null && tx.name.StartsWith("sky")) // !Q_strncmp(mt->name,"sky",3)) { this.Host.RenderContext.WarpableTextures.InitSky(tx); } else { tx.texture = BaseTexture.FromBuffer( this.Host.Video.Device, tx.name, new ByteArraySegment(tx.pixels), ( int )tx.width, ( int )tx.height, true, true); } }, (textureFile) => { var lowerName = textureFile.ToLower( ); if (this.Host.WadTextures.ContainsKey(lowerName)) { var wadFile = this.Host.WadTextures[lowerName]; var wad = this.Host.WadFiles[wadFile]; return(wad.GetLumpBuffer(textureFile)); } return(null); }); // // set up the submodels (FIXME: this is confusing) // for (var i = 0; i < mod.NumSubModels; i++) { mod.SetupSubModel(ref mod.SubModels[i]); if (i < mod.NumSubModels - 1) { // duplicate the basic information var name = "*" + (i + 1).ToString( ); this.CurrentModel = this.FindName(name, ModelType.mod_brush); this.CurrentModel.CopyFrom(mod); // *loadmodel = *mod; this.CurrentModel.Name = name; //strcpy (loadmodel->name, name); mod = ( BrushModelData )this.CurrentModel; //mod = loadmodel; } } }
/// <summary> /// Mod_FindName /// </summary> private ModelData FindName(String name, ModelType type) { ModelData result = null; if (String.IsNullOrEmpty(name)) { Utilities.Error("Mod_ForName: NULL name"); } if (!Contains(name)) { if (DictionaryItems.Count == ModelDef.MAX_MOD_KNOWN) { Utilities.Error("mod_numknown == MAX_MOD_KNOWN"); } switch (type) { case ModelType.Brush: result = new BrushModelData(Host.Model.SubdivideSize, Host.RenderContext.NoTextureMip); break; case ModelType.Sprite: result = new AliasModelData(Host.RenderContext.NoTextureMip); break; case ModelType.Alias: result = new SpriteModelData(Host.RenderContext.NoTextureMip); break; } result.Name = name; result.IsLoadRequired = true; Add(result.Name, result); } else { result = Get(name); } return(result); }
/// <summary> /// Mod_FindName /// </summary> public ModelData FindName(string name, ModelType type) { if (string.IsNullOrEmpty(name)) { Utilities.Error("Mod_ForName: NULL name"); } var mod = this.ModelCache.Where(m => m.Name == name).FirstOrDefault( ); if (mod == null) { if (this.ModelCache.Count == ModelDef.MAX_MOD_KNOWN) { Utilities.Error("mod_numknown == MAX_MOD_KNOWN"); } switch (type) { case ModelType.mod_brush: mod = new BrushModelData(this.Host.Model.SubdivideSize, this.Host.RenderContext.NoTextureMip); break; case ModelType.mod_sprite: mod = new AliasModelData(this.Host.RenderContext.NoTextureMip); break; case ModelType.mod_alias: mod = new SpriteModelData(this.Host.RenderContext.NoTextureMip); break; } mod.Name = name; mod.IsLoadRequired = true; this.ModelCache.Add(mod); } return(mod); }
public void Clear( ) { this.active = false; this.paused = false; this.loadgame = false; this.time = 0; this.lastcheck = 0; this.lastchecktime = 0; this.name = null; this.modelname = null; this.worldmodel = null; Array.Clear(this.model_precache, 0, this.model_precache.Length); Array.Clear(this.models, 0, this.models.Length); Array.Clear(this.sound_precache, 0, this.sound_precache.Length); Array.Clear(this.lightstyles, 0, this.lightstyles.Length); this.num_edicts = 0; this.max_edicts = 0; this.edicts = null; this.state = 0; this.datagram.Clear( ); this.reliable_datagram.Clear( ); this.signon.Clear( ); GC.Collect( ); }
public void Clear( ) { active = false; paused = false; loadgame = false; time = 0; lastcheck = 0; lastchecktime = 0; name = null; modelname = null; worldmodel = null; Array.Clear(model_precache, 0, model_precache.Length); Array.Clear(models, 0, models.Length); Array.Clear(sound_precache, 0, sound_precache.Length); Array.Clear(lightstyles, 0, lightstyles.Length); num_edicts = 0; max_edicts = 0; edicts = null; state = 0; datagram.Clear( ); reliable_datagram.Clear( ); signon.Clear( ); GC.Collect( ); }
/// <summary> /// Mod_LoadBrushModel /// </summary> private void LoadBrush(BrushModelData mod, Byte[] buffer) { mod.Load(mod.Name, buffer, (tx) => { if (tx.name != null && tx.name.StartsWith("sky")) // !Q_strncmp(mt->name,"sky",3)) { Host.RenderContext.WarpableTextures.InitSky(tx); } else { tx.texture = BaseTexture.FromBuffer(Host.Video.Device, tx.name, new ByteArraySegment(tx.pixels), ( Int32 )tx.width, ( Int32 )tx.height, true, true); } }, (textureFile) => { return(Host.Wads.LoadTexture(textureFile)); }); // // set up the submodels (FIXME: this is confusing) // for (var i = 0; i < mod.NumSubModels; i++) { mod.SetupSubModel(ref mod.SubModels[i]); if (i < mod.NumSubModels - 1) { // duplicate the basic information var name = "*" + (i + 1).ToString( ); CurrentModel = FindName(name, ModelType.Brush); CurrentModel.CopyFrom(mod); // *loadmodel = *mod; CurrentModel.Name = name; //strcpy (loadmodel->name, name); mod = ( BrushModelData )CurrentModel; //mod = loadmodel; } } }
/// <summary> /// Mod_LoadModel /// Loads a model into the cache /// </summary> public ModelData LoadModel(ModelData mod, bool crash, ModelType type) { var name = mod.Name; if (mod.Type != type) { ModelData newMod = null; switch (type) { case ModelType.mod_brush: newMod = new BrushModelData(this.Host.Model.SubdivideSize, this.Host.RenderContext.NoTextureMip); newMod.CopyFrom(mod); break; case ModelType.mod_alias: newMod = new AliasModelData(this.Host.RenderContext.NoTextureMip); newMod.CopyFrom(mod); break; case ModelType.mod_sprite: newMod = new SpriteModelData(this.Host.RenderContext.NoTextureMip); newMod.CopyFrom(mod); break; } newMod.Name = mod.Name; this.ModelCache.RemoveAll(k => k.Name == name); mod = newMod; this.ModelCache.Add(mod); } if (!mod.IsLoadRequired) { if (mod.Type == ModelType.mod_alias) { if (this.Host.Cache.Check(mod.cache) != null) { return(mod); } } else { return(mod); // not cached at all } } // // load the file // var buf = FileSystem.LoadFile(mod.Name); if (buf == null) { if (crash) { Utilities.Error("Mod_NumForName: {0} not found", mod.Name); } return(null); } // // allocate a new model // this.CurrentModel = mod; mod.IsLoadRequired = false; switch (BitConverter.ToUInt32(buf, 0)) // LittleLong(*(unsigned *)buf)) { case ModelDef.IDPOLYHEADER: this.LoadAliasModel(( AliasModelData )mod, buf); break; case ModelDef.IDSPRITEHEADER: this.LoadSpriteModel(( SpriteModelData )mod, buf); break; default: this.LoadBrushModel(( BrushModelData )mod, buf); break; } return(mod); }
/// <summary> /// Mod_LoadModel /// Loads a model into the cache /// </summary> private ModelData Load(ModelData mod, Boolean crash, ModelType type) { var name = mod.Name; if (mod.Type != type) { ModelData newMod = null; switch (type) { case ModelType.Brush: newMod = new BrushModelData(Host.Model.SubdivideSize, Host.RenderContext.NoTextureMip); newMod.CopyFrom(mod); break; case ModelType.Alias: newMod = new AliasModelData(Host.RenderContext.NoTextureMip); newMod.CopyFrom(mod); break; case ModelType.Sprite: newMod = new SpriteModelData(Host.RenderContext.NoTextureMip); newMod.CopyFrom(mod); break; } newMod.Name = mod.Name; Remove(name); mod = newMod; Add(mod.Name, mod); } if (!mod.IsLoadRequired) { if (mod.Type == ModelType.Alias) { if (Host.Cache.Check(mod.cache) != null) { return(mod); } } else { return(mod); // not cached at all } } // Load the file var buf = FileSystem.LoadFile(mod.Name); if (buf == null) { if (crash) { Utilities.Error("Mod_NumForName: {0} not found", mod.Name); } return(null); } // Allocate a new model Allocate(mod, buf); return(mod); }
public void Clear() { this.movemessages = 0; this.cmd.Clear(); Array.Clear(this.stats, 0, this.stats.Length); this.items = 0; Array.Clear(this.item_gettime, 0, this.item_gettime.Length); this.faceanimtime = 0; foreach (var cs in this.cshifts) { cs.Clear(); } foreach (var cs in this.prev_cshifts) { cs.Clear(); } this.mviewangles[0] = Vector3.Zero; this.mviewangles[1] = Vector3.Zero; this.viewangles = Vector3.Zero; this.mvelocity[0] = Vector3.Zero; this.mvelocity[1] = Vector3.Zero; this.velocity = Vector3.Zero; this.punchangle = Vector3.Zero; this.idealpitch = 0; this.pitchvel = 0; this.nodrift = false; this.driftmove = 0; this.laststop = 0; this.viewheight = 0; this.crouch = 0; this.paused = false; this.onground = false; this.inwater = false; this.intermission = 0; this.completed_time = 0; this.mtime[0] = 0; this.mtime[1] = 0; this.time = 0; this.oldtime = 0; this.last_received_message = 0; Array.Clear(this.model_precache, 0, this.model_precache.Length); Array.Clear(this.sound_precache, 0, this.sound_precache.Length); this.levelname = null; this.viewentity = 0; this.maxclients = 0; this.gametype = 0; this.worldmodel = null; this.free_efrags = null; this.num_entities = 0; this.num_statics = 0; this.viewent.Clear(); this.cdtrack = 0; this.looptrack = 0; this.scores = null; }
public void Clear() { movemessages = 0; cmd.Clear(); Array.Clear(stats, 0, stats.Length); items = 0; Array.Clear(item_gettime, 0, item_gettime.Length); faceanimtime = 0; foreach (var cs in cshifts) { cs.Clear(); } foreach (var cs in prev_cshifts) { cs.Clear(); } mviewangles[0] = Vector3.Zero; mviewangles[1] = Vector3.Zero; viewangles = Vector3.Zero; mvelocity[0] = Vector3.Zero; mvelocity[1] = Vector3.Zero; velocity = Vector3.Zero; punchangle = Vector3.Zero; idealpitch = 0; pitchvel = 0; nodrift = false; driftmove = 0; laststop = 0; viewheight = 0; crouch = 0; paused = false; onground = false; inwater = false; intermission = 0; completed_time = 0; mtime[0] = 0; mtime[1] = 0; time = 0; oldtime = 0; last_received_message = 0; Array.Clear(model_precache, 0, model_precache.Length); Array.Clear(sound_precache, 0, sound_precache.Length); levelname = null; viewentity = 0; maxclients = 0; gametype = 0; worldmodel = null; free_efrags = null; num_entities = 0; num_statics = 0; viewent.Clear(); cdtrack = 0; looptrack = 0; scores = null; }