Exemple #1
0
        private void GenerateObjectBitmapTables()
        {
            ObjBitmaps.Clear();
            ObjBitmapPointers.Clear();
            int      lastObjectBitmap        = VHAMFile.NumDescent2ObjBitmaps;
            int      lastObjectBitmapPointer = VHAMFile.NumDescent2ObjBitmapPointers;
            PIGImage img;
            EClip    clip;
            Dictionary <string, int> objectBitmapMapping = new Dictionary <string, int>();

            //Add the HAM file's object bitmaps so they can be referenced.
            for (int i = 0; i < BaseHAM.BaseFile.ObjBitmaps.Count; i++)
            {
                img = BaseHAM.piggyFile.GetImage(BaseHAM.BaseFile.ObjBitmaps[i]);
                if (!img.IsAnimated && !objectBitmapMapping.ContainsKey(img.Name))
                {
                    objectBitmapMapping.Add(img.Name, i);
                }
            }
            //Add EClip names
            for (int i = 0; i < BaseHAM.EClips.Count; i++)
            {
                clip = BaseHAM.EClips[i];
                if (clip.ChangingObjectTexture != -1)
                {
                    objectBitmapMapping.Add(clip.Name, clip.ChangingObjectTexture);
                }
            }

            Polymodel model;

            for (int i = 0; i < Models.Count; i++)
            {
                model = Models[i];
                model.FirstTexture = (ushort)lastObjectBitmapPointer;
                model.NumTextures  = (byte)model.TextureList.Count;
                foreach (string textureName in model.TextureList)
                {
                    if (!objectBitmapMapping.ContainsKey(textureName.ToLower()))
                    {
                        objectBitmapMapping.Add(textureName.ToLower(), lastObjectBitmap);
                        ObjBitmaps.Add((ushort)(BaseHAM.piggyFile.GetBitmapIDFromName(textureName)));
                        lastObjectBitmap++;
                    }
                    ObjBitmapPointers.Add((ushort)objectBitmapMapping[textureName.ToLower()]);
                    lastObjectBitmapPointer++;
                }
            }
        }
        private void GenerateObjectBitmapTables(bool compatObjBitmaps)
        {
            ObjBitmaps.Clear();
            ObjBitmapPointers.Clear();
            int lastObjectBitmap        = 0;
            int lastObjectBitmapPointer = 0;
            Dictionary <string, int> objectBitmapMapping = new Dictionary <string, int>();

            Polymodel model;

            if (compatObjBitmaps)
            {
                int lastShipmodel = PlayerShip.ModelNum;
                if (Models[PlayerShip.ModelNum].DyingModelnum != -1)
                {
                    lastShipmodel = Models[PlayerShip.ModelNum].DyingModelnum;
                }
                else if (Models[PlayerShip.ModelNum].SimplerModels != 0)
                {
                    lastShipmodel = Models[PlayerShip.ModelNum].SimplerModels - 1;
                }

                for (int i = 0; i < Models.Count; i++)
                {
                    model = Models[i];
                    model.FirstTexture = (ushort)lastObjectBitmapPointer;
                    model.NumTextures  = (byte)model.TextureList.Count;
                    if (i == lastShipmodel && i != PlayerShip.ModelNum)
                    {
                        //Inject multiplayer bitmaps
                        FirstMultiBitmapNum = lastObjectBitmapPointer;
                        for (int j = 0; j < 14; j++)
                        {
                            ObjBitmaps.Add((ushort)(multiplayerBitmaps[j])); ObjBitmapPointers.Add((ushort)(ObjBitmaps.Count - 1));
                            lastObjectBitmap++; lastObjectBitmapPointer++;
                        }
                        //Don't load textures for the dying ship. Because reasons.
                        model.FirstTexture = Models[PlayerShip.ModelNum].FirstTexture;
                        model.NumTextures  = Models[PlayerShip.ModelNum].NumTextures;
                    }
                    else
                    {
                        foreach (string textureName in model.TextureList)
                        {
                            if (EClipNameMapping.ContainsKey(textureName.ToLower()) && !objectBitmapMapping.ContainsKey(textureName.ToLower()))
                            {
                                objectBitmapMapping.Add(textureName.ToLower(), ObjBitmaps.Count);
                                ObjBitmaps.Add(0); //temp, will be remapped later
                                lastObjectBitmap++;
                            }
                            //In the compatible mode, all textures are redundant except vclips.
                            if (objectBitmapMapping.ContainsKey(textureName.ToLower()))
                            {
                                ObjBitmapPointers.Add((ushort)objectBitmapMapping[textureName.ToLower()]);
                                lastObjectBitmapPointer++;
                            }
                            else
                            {
                                ObjBitmapPointers.Add((ushort)lastObjectBitmap);
                                lastObjectBitmapPointer++;
                                ObjBitmaps.Add((ushort)(piggyFile.GetBitmapIDFromName(textureName)));
                                lastObjectBitmap++;
                            }
                        }
                        //I hate hacks, but parallax couldn't keep tabs on their bitmaps.tbl file so...
                        //Descent's smart missile children are defined with model textures despite not being models so for compatibility add them in
                        if (i == Weapons[18].ModelNum || i == Weapons[28].ModelNum) //player and robot mega missiles
                        {
                            ObjBitmaps.Add((ushort)(piggyFile.GetBitmapIDFromName("glow04"))); ObjBitmapPointers.Add((ushort)(ObjBitmaps.Count - 1));
                            ObjBitmaps.Add((ushort)(piggyFile.GetBitmapIDFromName("rbot046"))); ObjBitmapPointers.Add((ushort)(ObjBitmaps.Count - 1));
                            lastObjectBitmapPointer += 2; lastObjectBitmap += 2;
                        }

                        //ugh
                        if (i == lastShipmodel && i == PlayerShip.ModelNum)
                        {
                            //Inject multiplayer bitmaps
                            FirstMultiBitmapNum = lastObjectBitmapPointer;
                            for (int j = 0; j < 14; j++)
                            {
                                ObjBitmaps.Add((ushort)(multiplayerBitmaps[j])); ObjBitmapPointers.Add((ushort)(ObjBitmaps.Count - 1));
                                lastObjectBitmap++; lastObjectBitmapPointer++;
                            }
                        }
                    }
                }
            }
            else
            {
                for (int i = 0; i < Models.Count; i++)
                {
                    model = Models[i];
                    model.FirstTexture = (ushort)lastObjectBitmapPointer;
                    model.NumTextures  = (byte)model.TextureList.Count;
                    foreach (string textureName in model.TextureList)
                    {
                        if (!objectBitmapMapping.ContainsKey(textureName.ToLower()))
                        {
                            objectBitmapMapping.Add(textureName.ToLower(), lastObjectBitmap);
                            ObjBitmaps.Add((ushort)(piggyFile.GetBitmapIDFromName(textureName)));
                            lastObjectBitmap++;
                        }
                        ObjBitmapPointers.Add((ushort)objectBitmapMapping[textureName.ToLower()]);
                        lastObjectBitmapPointer++;
                    }
                }
                //Inject multiplayer bitmaps
                FirstMultiBitmapNum = lastObjectBitmapPointer;
                for (int i = 0; i < 14; i++)
                {
                    ObjBitmaps.Add((ushort)(multiplayerBitmaps[i])); ObjBitmapPointers.Add((ushort)(ObjBitmaps.Count - 1));
                }
            }

            //Update EClips
            EClip clip;

            for (int i = 0; i < EClips.Count; i++)
            {
                clip = EClips[i];
                if (objectBitmapMapping.ContainsKey(EClips[i].Name.ToLower()))
                {
                    clip.ChangingObjectTexture             = (short)objectBitmapMapping[EClips[i].Name.ToLower()];
                    ObjBitmaps[clip.ChangingObjectTexture] = (ushort)(clip.Clip.Frames[0]);
                }
            }
        }