Ejemplo n.º 1
0
        static void PrintFrameName(model_t m, int frame)
        {
            aliashdr_t hdr = Mod.GetExtraData(m);

            if (hdr == null)
            {
                return;
            }

            Con.Print("frame {0}: {1}\n", frame, hdr.frames[frame].name);
        }
Ejemplo n.º 2
0
Archivo: Mesh.cs Proyecto: Scrama/Quarp
        static int _StripCount;                            // stripcount

        /// <summary>
        /// GL_MakeAliasModelDisplayLists
        /// </summary>
        public static void MakeAliasModelDisplayLists(model_t m, aliashdr_t hdr)
        {
            _AliasModel = m;
            _AliasHdr   = hdr;

            //
            // look for a cached version
            //
            string path = Path.ChangeExtension("glquake/" + Path.GetFileNameWithoutExtension(m.name), ".ms2");

            DisposableWrapper <BinaryReader> file;

            Common.FOpenFile(path, out file);
            if (file != null)
            {
                using (file)
                {
                    BinaryReader reader = file.Object;
                    _NumCommands = reader.ReadInt32();
                    _NumOrder    = reader.ReadInt32();
                    for (int i = 0; i < _NumCommands; i++)
                    {
                        _Commands[i] = reader.ReadInt32();
                    }
                    for (int i = 0; i < _NumOrder; i++)
                    {
                        _VertexOrder[i] = reader.ReadInt32();
                    }
                }
            }
            else
            {
                //
                // build it from scratch
                //
                Con.Print("meshing {0}...\n", m.name);

                BuildTris();            // trifans or lists

                //
                // save out the cached version
                //
                string fullpath = Path.Combine(Common.GameDir, path);
                Stream fs       = Sys.FileOpenWrite(fullpath, true);
                if (fs != null)
                {
                    using (BinaryWriter writer = new BinaryWriter(fs, Encoding.ASCII))
                    {
                        writer.Write(_NumCommands);
                        writer.Write(_NumOrder);
                        for (int i = 0; i < _NumCommands; i++)
                        {
                            writer.Write(_Commands[i]);
                        }
                        for (int i = 0; i < _NumOrder; i++)
                        {
                            writer.Write(_VertexOrder[i]);
                        }
                    }
                }
            }

            //
            // save the data out
            //
            _AliasHdr.poseverts = _NumOrder;

            int[] cmds = new int[_NumCommands];                        //Hunk_Alloc (numcommands * 4);
            _AliasHdr.commands = cmds;                                 // in bytes??? // (byte*)cmds - (byte*)paliashdr;
            Buffer.BlockCopy(_Commands, 0, cmds, 0, _NumCommands * 4); //memcpy (cmds, commands, numcommands * 4);

            trivertx_t[][] poseverts = Mod.PoseVerts;
            trivertx_t[]   verts     = new trivertx_t[_AliasHdr.numposes * _AliasHdr.poseverts]; // Hunk_Alloc (paliashdr->numposes * paliashdr->poseverts * sizeof(trivertx_t) );
            _AliasHdr.posedata = verts;                                                          // (byte*)verts - (byte*)paliashdr;
            int offset = 0;

            for (int i = 0; i < _AliasHdr.numposes; i++)
            {
                for (int j = 0; j < _NumOrder; j++)
                {
                    verts[offset++] = poseverts[i][_VertexOrder[j]];  // *verts++ = poseverts[i][vertexorder[j]];
                }
            }
        }