コード例 #1
0
        /// <summary>
        /// Mod_LoadAliasFrame
        /// </summary>
        /// <returns>Offset of next data block in source byte array</returns>
        private Int32 LoadAliasFrame(ByteArraySegment pin, ref maliasframedesc_t frame)
        {
            var pdaliasframe = Utilities.BytesToStructure <daliasframe_t>(pin.Data, pin.StartIndex);

            frame.name      = Utilities.GetString(pdaliasframe.name);
            frame.firstpose = PoseNum;
            frame.numposes  = 1;
            frame.bboxmin.Init( );
            frame.bboxmax.Init( );

            for (var i = 0; i < 3; i++)
            {
                // these are byte values, so we don't have to worry about
                // endianness
                frame.bboxmin.v[i] = pdaliasframe.bboxmin.v[i];
                frame.bboxmax.v[i] = pdaliasframe.bboxmax.v[i];
            }

            var verts  = new trivertx_t[Header.numverts];
            var offset = pin.StartIndex + daliasframe_t.SizeInBytes; //pinframe = (trivertx_t*)(pdaliasframe + 1);

            for (var i = 0; i < verts.Length; i++, offset += trivertx_t.SizeInBytes)
            {
                verts[i] = Utilities.BytesToStructure <trivertx_t>(pin.Data, offset);
            }
            _PoseVerts[PoseNum] = verts;
            PoseNum++;

            return(offset);
        }
コード例 #2
0
ファイル: mesh.cs プロジェクト: IceReaper/SharpQuake
        private static int _StripCount;                                 // stripcount

        /// <summary>
        /// GL_MakeAliasModelDisplayLists
        /// </summary>
        public static void MakeAliasModelDisplayLists(AliasModelData m)
        {
            mesh._AliasModel = m;
            mesh._AliasHdr   = m.Header;

            //
            // build it from scratch
            //
            mesh.BuildTris(m);                  // trifans or lists

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

            var cmds = new int[mesh._NumCommands];                               //Hunk_Alloc (numcommands * 4);

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

            var poseverts = m.PoseVerts;
            var verts     = new trivertx_t[mesh._AliasHdr.numposes * mesh._AliasHdr.poseverts]; // Hunk_Alloc (paliashdr->numposes * paliashdr->poseverts * sizeof(trivertx_t) );

            mesh._AliasHdr.posedata = verts;                                                    // (byte*)verts - (byte*)paliashdr;
            var offset = 0;

            for (var i = 0; i < mesh._AliasHdr.numposes; i++)
            {
                for (var j = 0; j < mesh._NumOrder; j++)
                {
                    verts[offset++] = poseverts[i][mesh._VertexOrder[j]];  // *verts++ = poseverts[i][vertexorder[j]];
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Mod_LoadAliasGroup
        /// </summary>
        /// <returns>Offset of next data block in source byte array</returns>
        private int LoadAliasGroup(ByteArraySegment pin, ref maliasframedesc_t frame)
        {
            var offset    = pin.StartIndex;
            var pingroup  = Utilities.BytesToStructure <daliasgroup_t>(pin.Data, offset);
            var numframes = EndianHelper.LittleLong(pingroup.numframes);

            frame.Init( );
            frame.firstpose = this.PoseNum;
            frame.numposes  = numframes;

            for (var i = 0; i < 3; i++)
            {
                // these are byte values, so we don't have to worry about endianness
                frame.bboxmin.v[i] = pingroup.bboxmin.v[i];
                frame.bboxmin.v[i] = pingroup.bboxmax.v[i];
            }

            offset += daliasgroup_t.SizeInBytes;
            var pin_intervals = Utilities.BytesToStructure <daliasinterval_t>(pin.Data, offset);  // (daliasinterval_t*)(pingroup + 1);

            frame.interval = EndianHelper.LittleFloat(pin_intervals.interval);

            offset += numframes * daliasinterval_t.SizeInBytes;

            for (var i = 0; i < numframes; i++)
            {
                var tris    = new trivertx_t[this.Header.numverts];
                var offset1 = offset + daliasframe_t.SizeInBytes;
                for (var j = 0; j < this.Header.numverts; j++, offset1 += trivertx_t.SizeInBytes)
                {
                    tris[j] = Utilities.BytesToStructure <trivertx_t>(pin.Data, offset1);
                }

                this._PoseVerts[this.PoseNum] = tris;
                this.PoseNum++;

                offset += daliasframe_t.SizeInBytes + this.Header.numverts * trivertx_t.SizeInBytes;
            }

            return(offset);
        }
コード例 #4
0
    public static void GL_MakeAliasModelDisplayLists(model_t m, aliashdr_t hdr)
    {
        aliasmodel = m;
        paliashdr  = hdr;

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

        DisposableWrapper <BinaryReader> file;

        COM_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_Printf("meshing {0}...\n", m.name);

            BuildTris();                // trifans or lists

            //
            // save out the cached version
            //
            string fullpath = Path.Combine(com_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
        //
        paliashdr.poseverts = numorder;

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

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

        for (int i = 0; i < paliashdr.numposes; i++)
        {
            for (int j = 0; j < numorder; j++)
            {
                verts[offset++] = poseverts[i][vertexorder[j]];  // *verts++ = poseverts[i][vertexorder[j]];
            }
        }
    }
コード例 #5
0
ファイル: model.cs プロジェクト: rodrigobrito/quakelight
        /*
        =================
        Mod_LoadAliasGroup
        =================
        */
        static void Mod_LoadAliasGroup(bspfile.ByteBuffer pin, ref object pframeindex, int numv,
            trivertx_t pbboxmin, trivertx_t pbboxmax, aliashdr_t pheader, string name)
        {
            daliasgroup_t		pingroup;
            maliasgroup_t		paliasgroup;
            int					i, numframes;
            double[]			poutintervals;

            pingroup = (daliasgroup_t)pin;

            numframes = pingroup.numframes;

            paliasgroup = new maliasgroup_t();
            paliasgroup.frames = new maliasgroupframedesc_t[numframes];
            for (int kk = 0; kk < numframes; kk++) paliasgroup.frames[kk] = new maliasgroupframedesc_t();

            paliasgroup.numframes = numframes;

            for (i=0 ; i<3 ; i++)
            {
            // these are byte values, so we don't have to worry about endianness
                pbboxmin.v[i] = pingroup.bboxmin.v[i];
                pbboxmax.v[i] = pingroup.bboxmax.v[i];
            }

            pframeindex = (object)paliasgroup;

            pin.ofs += sizeof_daliasgroup_t;

            poutintervals = new double[numframes];

            paliasgroup.intervals = poutintervals;

            for (i = 0; i < numframes; i++)
            {
                poutintervals[i] = BitConverter.ToSingle(pin.buffer, pin.ofs); pin.ofs += sizeof(Single);
                if (poutintervals[i] <= 0.0)
                    sys_linux.Sys_Error("Mod_LoadAliasGroup: interval<=0");
            }

            for (i=0 ; i<numframes ; i++)
            {
                Mod_LoadAliasFrame (pin,
                                    ref paliasgroup.frames[i].frame,
                                    numv,
                                    paliasgroup.frames[i].bboxmin,
                                    paliasgroup.frames[i].bboxmax,
                                    pheader, name);
            }
        }
コード例 #6
0
ファイル: model.cs プロジェクト: rodrigobrito/quakelight
        /*
        ==============================================================================

        ALIAS MODELS

        ==============================================================================
        */
        /*
        =================
        Mod_LoadAliasFrame
        =================
        */
        static void Mod_LoadAliasFrame(bspfile.ByteBuffer pin, ref object pframeindex, int numv,
            trivertx_t pbboxmin, trivertx_t pbboxmax, aliashdr_t pheader, string name)
        {
            trivertx_t[]	pframe;
            trivertx_t      pinframe;
            int				i, j;
            daliasframe_t	pdaliasframe;

            pdaliasframe = (daliasframe_t)pin;

            name = pdaliasframe.name;

            for (i=0 ; i<3 ; i++)
            {
            // these are byte values, so we don't have to worry about
            // endianness
                pbboxmin.v[i] = pdaliasframe.bboxmin.v[i];
                pbboxmax.v[i] = pdaliasframe.bboxmax.v[i];
            }

            pin.ofs += sizeof_daliasframe_t;
            pframe = new trivertx_t[numv];

            pframeindex = (object)pframe;

            for (j=0 ; j<numv ; j++)
            {
                int		k;

                pinframe = (trivertx_t)pin;

            // these are all byte values, so no need to deal with endianness
                pframe[j] = new trivertx_t();
                pframe[j].lightnormalindex = pinframe.lightnormalindex;

                for (k=0 ; k<3 ; k++)
                {
                    pframe[j].v[k] = pinframe.v[k];
                }
                pin.ofs += sizeof_trivertx_t;
            }
        }