Exemple #1
0
        /*
        =================
        Mod_LoadFaces
        =================
        */
        static void Mod_LoadFaces(bspfile.lump_t l)
        {
            bspfile.dface_t[]   @in;
            msurface_t[] 	    @out;
            int			        i, count, surfnum;
            int			        planenum, side;

            if ((l.filelen % bspfile.sizeof_dface_t) != 0)
                sys_linux.Sys_Error ("MOD_LoadBmodel: funny lump size in " + loadmodel.name);
            count = l.filelen / bspfile.sizeof_dface_t;
            bspfile.ByteBuffer buf = new bspfile.ByteBuffer(mod_base, l.fileofs);
            @in = new bspfile.dface_t[count];
            @out = new msurface_t[count];
            for (int kk = 0; kk < count; kk++)
            {
                @in[kk] = (bspfile.dface_t)buf;
                buf.ofs += bspfile.sizeof_dface_t;
                @out[kk] = new msurface_t();
            }

            loadmodel.surfaces = @out;
            loadmodel.numsurfaces = count;

            int color = colors[(icolor++) % 8];
            for ( surfnum=0 ; surfnum<count ; surfnum++)
            {
                @out[surfnum].firstedge = @in[surfnum].firstedge;
                @out[surfnum].numedges = @in[surfnum].numedges;
                @out[surfnum].flags = 0;

                planenum = @in[surfnum].planenum;
                side = @in[surfnum].side;
                if (side != 0)
                    @out[surfnum].flags |= SURF_PLANEBACK;

                @out[surfnum].plane = loadmodel.planes[planenum];

                @out[surfnum].color = color;
                color += 0x40;

                @out[surfnum].texinfo = loadmodel.texinfo[@in[surfnum].texinfo];

                CalcSurfaceExtents (@out[surfnum]);

            // lighting info

                for (i=0 ; i<bspfile.MAXLIGHTMAPS ; i++)
                    @out[surfnum].styles[i] = @in[surfnum].styles[i];
                i = @in[surfnum].lightofs;
                if (i == -1)
                    @out[surfnum].samples = null;
                else
                    @out[surfnum].samples = new bspfile.ByteBuffer(loadmodel.lightdata, i);

            // set the drawing flags flag

                if (@out[surfnum].texinfo.texture.name.StartsWith("sky"))	// sky
                {
                    @out[surfnum].flags |= (SURF_DRAWSKY | SURF_DRAWTILED);
                    continue;
                }

                if (@out[surfnum].texinfo.texture.name.StartsWith("*"))		// turbulent
                {
                    @out[surfnum].flags |= (SURF_DRAWTURB | SURF_DRAWTILED);
                    for (i=0 ; i<2 ; i++)
                    {
                        @out[surfnum].extents[i] = 16384;
                        @out[surfnum].texturemins[i] = -8192;
                    }
                    continue;
                }
            }
        }
Exemple #2
0
        /*
        =================
        Mod_LoadAliasModel
        =================
        */
        static void Mod_LoadAliasModel(model_t mod, byte[] buffer)
        {
            int					i;
            mdl_t				pmodel, pinmodel;
            stvert_t[]			pstverts;
            stvert_t            pinstverts;
            aliashdr_t			pheader;
            mtriangle_t[]       ptri;
            dtriangle_t         pintriangles;
            int                 version, numframes, numskins;
            daliasframetype_t   pframetype;
            daliasskintype_t    pskintype;
            maliasskindesc_t[]  pskindesc;
            int                 skinsize;
            int					start, end, total;
            bspfile.ByteBuffer  aux = new bspfile.ByteBuffer(buffer, 0);

            pinmodel = (mdl_t)buffer;

            version = pinmodel.version;
            if (version != ALIAS_VERSION)
                sys_linux.Sys_Error (mod.name + " has wrong version number (" + version + " should be " + ALIAS_VERSION + ")");

            //
            // allocate space for a working header, plus all the data except the frames,
            // skin and group info
            //
            pheader = new aliashdr_t();
            pmodel = new mdl_t();

            //	mod.cache = pheader;
            mod.flags = pinmodel.flags;

            //
            // endian-adjust and copy the data, starting with the alias model header
            //
            pmodel.boundingradius = pinmodel.boundingradius;
            pmodel.numskins = pinmodel.numskins;
            pmodel.skinwidth = pinmodel.skinwidth;
            pmodel.skinheight = pinmodel.skinheight;

            if (pmodel.skinheight > draw.MAX_LBM_HEIGHT)
                sys_linux.Sys_Error("model " + mod.name + " has a skin taller than " + draw.MAX_LBM_HEIGHT);

            pmodel.numverts = pinmodel.numverts;

            if (pmodel.numverts <= 0)
                sys_linux.Sys_Error("model " + mod.name + " has no vertices");

            if (pmodel.numverts > render.MAXALIASVERTS)
                sys_linux.Sys_Error("model " + mod.name + " has too many vertices");

            pmodel.numtris = pinmodel.numtris;

            if (pmodel.numtris <= 0)
                sys_linux.Sys_Error("model " + mod.name + " has no triangles");

            pmodel.numframes = pinmodel.numframes;
            pmodel.size = pinmodel.size * render.ALIAS_BASE_SIZE_RATIO;
            mod.synctype = pinmodel.synctype;
            mod.numframes = pmodel.numframes;

            for (i = 0; i < 3; i++)
            {
                pmodel.scale[i] = pinmodel.scale[i];
                pmodel.scale_origin[i] = pinmodel.scale_origin[i];
                pmodel.eyeposition[i] = pinmodel.eyeposition[i];
            }

            numskins = pmodel.numskins;
            numframes = pmodel.numframes;

            if ((pmodel.skinwidth & 0x03) != 0)
                sys_linux.Sys_Error("Mod_LoadAliasModel: skinwidth not multiple of 4");

            pheader.model = pmodel;

            //
            // load the skins
            //
            skinsize = pmodel.skinheight * pmodel.skinwidth;

            if (numskins < 1)
                sys_linux.Sys_Error("Mod_LoadAliasModel: Invalid # of skins: " + numskins + "\n");

            aux.ofs += sizeof_mdl_t;

            pskindesc = new maliasskindesc_t[numskins];
            for(int kk = 0; kk < numskins; kk++) pskindesc[kk] = new maliasskindesc_t();

            pheader.skindesc = pskindesc;

            for (i = 0; i < numskins; i++)
            {
                aliasskintype_t skintype;

                pskintype = (daliasskintype_t)aux;
                skintype = pskintype.type;
                pskindesc[i].type = skintype;

                if (skintype == aliasskintype_t.ALIAS_SKIN_SINGLE)
                {
                    aux.ofs += sizeof_daliasskintype_t;
                    Mod_LoadAliasSkin(aux, ref pskindesc[i].skin, skinsize, pheader);
                }
                else
                {
                    aux.ofs += sizeof_daliasskintype_t;
                    Mod_LoadAliasSkinGroup(aux, ref pskindesc[i].skin, skinsize, pheader);
                }
            }

            //
            // set base s and t vertices
            //
            pstverts = new stvert_t[pmodel.numverts];

            pheader.stverts = pstverts;

            for (i = 0; i < pmodel.numverts; i++)
            {
                pinstverts = (stvert_t)aux;
                pstverts[i] = new stvert_t();
                pstverts[i].onseam = pinstverts.onseam;
                // put s and t in 16.16 format
                pstverts[i].s = pinstverts.s << 16;
                pstverts[i].t = pinstverts.t << 16;
                aux.ofs += sizeof_stvert_t;
            }

            //
            // set up the triangles
            //
            ptri = new mtriangle_t[pmodel.numtris];

            pheader.triangles = ptri;

            for (i = 0; i < pmodel.numtris; i++)
            {
                int j;

                pintriangles = (dtriangle_t)aux;
                ptri[i] = new mtriangle_t();
                ptri[i].facesfront = pintriangles.facesfront;

                for (j = 0; j < 3; j++)
                {
                    ptri[i].vertindex[j] =
                            pintriangles.vertindex[j];
                }
                aux.ofs += sizeof_dtriangle_t;
            }

            //
            // load the frames
            //
            if (numframes < 1)
                sys_linux.Sys_Error("Mod_LoadAliasModel: Invalid # of frames: " + numframes + "\n");

            pheader.frames = new maliasframedesc_t[numframes];
            for (i = 0; i < numframes; i++)
            {
                aliasframetype_t frametype;

                pframetype = (daliasframetype_t)aux;
                frametype = pframetype.type;
                pheader.frames[i] = new maliasframedesc_t();
                pheader.frames[i].type = frametype;

                if (frametype == aliasframetype_t.ALIAS_SINGLE)
                {
                    aux.ofs += sizeof_daliasframetype_t;
                    Mod_LoadAliasFrame(aux,
                                        ref pheader.frames[i].frame,
                                        pmodel.numverts,
                                        pheader.frames[i].bboxmin,
                                        pheader.frames[i].bboxmax,
                                        pheader, pheader.frames[i].name);
                }
                else
                {
                    aux.ofs += sizeof_daliasframetype_t;
                    Mod_LoadAliasGroup(aux,
                                        ref pheader.frames[i].frame,
                                        pmodel.numverts,
                                        pheader.frames[i].bboxmin,
                                        pheader.frames[i].bboxmax,
                                        pheader, pheader.frames[i].name);
                }
            }

            mod.type = modtype_t.mod_alias;

            // FIXME: do this right
            mod.mins[0] = mod.mins[1] = mod.mins[2] = -16;
            mod.maxs[0] = mod.maxs[1] = mod.maxs[2] = 16;

            //
            // move the complete, relocatable alias model to the cache
            //
            mod.cache = pheader;
        }
Exemple #3
0
        /*
        =================
        Mod_LoadEdges
        =================
        */
        static void Mod_LoadEdges(bspfile.lump_t l)
        {
            bspfile.dedge_t[]   @in;
            medge_t[]           @out;
            int 	            i, count;

            if ((l.filelen % bspfile.sizeof_dedge_t) != 0)
                sys_linux.Sys_Error ("MOD_LoadBmodel: funny lump size in " + loadmodel.name);
            count = l.filelen / bspfile.sizeof_dedge_t;
            bspfile.ByteBuffer buf = new bspfile.ByteBuffer(mod_base, l.fileofs);
            @in = new bspfile.dedge_t[count];
            @out = new medge_t[count];
            for (int kk = 0; kk < count; kk++)
            {
                @in[kk] = (bspfile.dedge_t)buf;
                buf.ofs += bspfile.sizeof_dedge_t;
                @out[kk] = new medge_t();
            }

            loadmodel.edges = @out;
            loadmodel.numedges = count;

            for ( i=0 ; i<count ; i++)
            {
                @out[i].v[0] = (ushort)@in[i].v[0];
                @out[i].v[1] = (ushort)@in[i].v[1];
            }
        }
Exemple #4
0
        /*
        =================
        Mod_LoadTextures
        =================
        */
        static void Mod_LoadTextures(bspfile.lump_t l)
        {
            int		                i, j, pixels, num, max, altmax;
            bspfile.miptex_t	    mt;
            texture_t	            tx, tx2;
            texture_t[]	            anims = new texture_t[10];
            texture_t[]	            altanims = new texture_t[10];
            bspfile.dmiptexlump_t   m;

            for(int kk = 0; kk < 10; kk++)
            {
                anims[kk] = new texture_t();
                altanims[kk] = new texture_t();
            }

            if (l.filelen == 0)
            {
                loadmodel.textures = null;
                return;
            }
            bspfile.ByteBuffer buf = new bspfile.ByteBuffer(mod_base, l.fileofs);
            m = (bspfile.dmiptexlump_t)buf;

            loadmodel.numtextures = m.nummiptex;
            loadmodel.textures = new texture_t[m.nummiptex];

            for (i=0 ; i<m.nummiptex ; i++)
            {
                loadmodel.textures[i] = new texture_t();
                if (m.dataofs[i] == -1)
                    continue;
                buf.ofs = l.fileofs + m.dataofs[i];
                mt = (bspfile.miptex_t)buf;

                if ( (mt.width & 15) != 0 || (mt.height & 15) != 0 )
                    sys_linux.Sys_Error ("Texture " + mt.name + " is not 16 aligned");
                pixels = (int)(mt.width*mt.height/64*85);
                tx = new texture_t();
                tx.pixels = new byte[pixels];
                loadmodel.textures[i] = tx;

                tx.name = mt.name;
                tx.width = mt.width;
                tx.height = mt.height;
                for (j=0 ; j<bspfile.MIPLEVELS ; j++)
                    tx.offsets[j] = mt.offsets[j]/* + sizeof_texture_t*/ - bspfile.sizeof_miptex_t;
                // the pixels immediately follow the structures
                Buffer.BlockCopy(buf.buffer, buf.ofs + bspfile.sizeof_miptex_t, tx.pixels, 0, pixels);

                if (mt.name.StartsWith("sky"))
                    render.R_InitSky(tx);
            }

            //
            // sequence the animations
            //
            for (i=0 ; i<m.nummiptex ; i++)
            {
                tx = loadmodel.textures[i];
                if (tx == null || tx.name[0] != '+')
                    continue;
             		        if (tx.anim_next != null)
                    continue;	// allready sequenced

            // find the number of frames in the animation
                //memset (anims, 0, sizeof(anims));
                //memset (altanims, 0, sizeof(altanims));

                max = tx.name[1];
                altmax = 0;
                if (max >= 'a' && max <= 'z')
                    max -= 'a' - 'A';
                if (max >= '0' && max <= '9')
                {
                    max -= '0';
                    altmax = 0;
                    anims[max] = tx;
                    max++;
                }
                else if (max >= 'A' && max <= 'J')
                {
                    altmax = max - 'A';
                    max = 0;
                    altanims[altmax] = tx;
             			        altmax++;
                }
                else
                    sys_linux.Sys_Error ("Bad animating texture " + tx.name);

                for (j=i+1 ; j<m.nummiptex ; j++)
                {
                    tx2 = loadmodel.textures[j];
                    if (tx2 == null || tx2.name[0] != '+')
                        continue;
                    if (tx2.name.Substring(2).CompareTo(tx.name.Substring(2)) != 0)
                        continue;

                    num = tx2.name[1];
                    if (num >= 'a' && num <= 'z')
                        num -= 'a' - 'A';
                    if (num >= '0' && num <= '9')
                    {
                        num -= '0';
                        anims[num] = tx2;
                        if (num+1 > max)
                            max = num + 1;
                    }
                    else if (num >= 'A' && num <= 'J')
                    {
                        num = num - 'A';
                        altanims[num] = tx2;
                        if (num+1 > altmax)
                            altmax = num+1;
                    }
                    else
                        sys_linux.Sys_Error ("Bad animating texture " + tx.name);
                }

            // link them all together
                for (j=0 ; j<max ; j++)
                {
                    tx2 = anims[j];
                    if (tx2 == null)
                        sys_linux.Sys_Error ("Missing frame " + j + " of " + tx.name);
                    tx2.anim_total = max * ANIM_CYCLE;
                    tx2.anim_min = j * ANIM_CYCLE;
                    tx2.anim_max = (j+1) * ANIM_CYCLE;
                    tx2.anim_next = anims[ (j+1)%max ];
                    if (altmax != 0)
                        tx2.alternate_anims = altanims[0];
                }
                for (j=0 ; j<altmax ; j++)
                {
                    tx2 = altanims[j];
                    if (tx2 == null)
                        sys_linux.Sys_Error ("Missing frame " + j + " of " + tx.name);
                    tx2.anim_total = altmax * ANIM_CYCLE;
                    tx2.anim_min = j * ANIM_CYCLE;
                    tx2.anim_max = (j+1) * ANIM_CYCLE;
                    tx2.anim_next = altanims[ (j+1)%altmax ];
                    if (max != 0)
                        tx2.alternate_anims = anims[0];
                }
            }
        }
Exemple #5
0
        /*
        =================
        Mod_LoadVertexes
        =================
        */
        static void Mod_LoadVertexes(bspfile.lump_t l)
        {
            bspfile.dvertex_t[]	@in;
            mvertex_t[]	        @out;
            int			        i, count;

            if ((l.filelen % bspfile.sizeof_dvertex_t) != 0)
                sys_linux.Sys_Error ("MOD_LoadBmodel: funny lump size in " + loadmodel.name);
            count = l.filelen / bspfile.sizeof_dvertex_t;
            bspfile.ByteBuffer buf = new bspfile.ByteBuffer(mod_base, l.fileofs);
            @in = new bspfile.dvertex_t[count];
            @out = new mvertex_t[count];
            for (int kk = 0; kk < count; kk++)
            {
                @in[kk] = (bspfile.dvertex_t)buf;
                buf.ofs += bspfile.sizeof_dvertex_t;
                @out[kk] = new mvertex_t();
            }

            loadmodel.vertexes = @out;
            loadmodel.numvertexes = count;

            for ( i=0 ; i<count ; i++)
            {
                @out[i].position[0] = @in[i].point[0];
                @out[i].position[1] = @in[i].point[1];
                @out[i].position[2] = @in[i].point[2];
            }
        }
Exemple #6
0
        /*
        =================
        Mod_LoadSubmodels
        =================
        */
        static void Mod_LoadSubmodels(bspfile.lump_t l)
        {
            bspfile.dmodel_t[]	@out;
            int			        i, j, count;

            if ((l.filelen % bspfile.sizeof_dmodel_t) != 0)
                sys_linux.Sys_Error ("MOD_LoadBmodel: funny lump size in " + loadmodel.name);
            count = l.filelen / bspfile.sizeof_dmodel_t;
            @out = new bspfile.dmodel_t[count];
            bspfile.ByteBuffer buf = new bspfile.ByteBuffer(mod_base, l.fileofs);
            for (int kk = 0; kk < count; kk++)
            {
                @out[kk] = (bspfile.dmodel_t)buf;
                buf.ofs += bspfile.sizeof_dmodel_t;
            }

            loadmodel.submodels = @out;
            loadmodel.numsubmodels = count;

            for ( i=0 ; i<count ; i++)
            {
                for (j=0 ; j<3 ; j++)
                {	// spread the mins / maxs by a pixel
                    @out[i].mins[j] -= 1;
                    @out[i].maxs[j] += 1;
                }
            }
        }
Exemple #7
0
        /*
        =================
        Mod_LoadTexinfo
        =================
        */
        static void Mod_LoadTexinfo(bspfile.lump_t l)
        {
            bspfile.texinfo_t[] @in;
            mtexinfo_t[]        @out;
            int 	            i, j, count;
            int		            miptex;
            double	            len1, len2;

            if ((l.filelen % bspfile.sizeof_texinfo_t) != 0)
                sys_linux.Sys_Error ("MOD_LoadBmodel: funny lump size in " + loadmodel.name);
            count = l.filelen / bspfile.sizeof_texinfo_t;
            bspfile.ByteBuffer buf = new bspfile.ByteBuffer(mod_base, l.fileofs);
            @in = new bspfile.texinfo_t[count];
            @out = new mtexinfo_t[count];
            for (int kk = 0; kk < count; kk++)
            {
                @in[kk] = (bspfile.texinfo_t)buf;
                buf.ofs += bspfile.sizeof_texinfo_t;
                @out[kk] = new mtexinfo_t();
            }

            loadmodel.texinfo = @out;
            loadmodel.numtexinfo = count;

            for ( i=0 ; i<count ; i++)
            {
                for(int k = 0; k < 2; k++)
                    for (j=0 ; j<4 ; j++)
                        @out[i].vecs[k][j] = @in[i].vecs[k][j];
                len1 = mathlib.Length (@out[i].vecs[0]);
                len2 = mathlib.Length (@out[i].vecs[1]);
                len1 = (len1 + len2)/2;
                if (len1 < 0.32)
                    @out[i].mipadjust = 4;
                else if (len1 < 0.49)
                    @out[i].mipadjust = 3;
                else if (len1 < 0.99)
                    @out[i].mipadjust = 2;
                else
                    @out[i].mipadjust = 1;

                miptex = @in[i].miptex;
                @out[i].flags = @in[i].flags;

                if (loadmodel.textures == null)
                {
                    @out[i].texture = render.r_notexture_mip;	// checkerboard texture
                    @out[i].flags = 0;
                }
                else
                {
                    if (miptex >= loadmodel.numtextures)
                        sys_linux.Sys_Error ("miptex >= loadmodel.numtextures");
                    @out[i].texture = loadmodel.textures[miptex];
                    if (@out[i].texture == null)
                    {
                        @out[i].texture = render.r_notexture_mip; // texture not found
                        @out[i].flags = 0;
                    }
                }
            }
        }
Exemple #8
0
        /*
        =================
        Mod_LoadSpriteModel
        =================
        */
        static void Mod_LoadSpriteModel(model_t mod, byte[] buffer)
        {
            int					i;
            int					version;
            dsprite_t			pin;
            msprite_t			psprite;
            int					numframes;
            dspriteframetype_t	pframetype;
            bspfile.ByteBuffer  aux = new bspfile.ByteBuffer(buffer, 0);

            pin = (dsprite_t)buffer;

            version = pin.version;
            if (version != SPRITE_VERSION)
                sys_linux.Sys_Error (mod.name + " has wrong version number (" + version + " should be " + SPRITE_VERSION + ")");

            numframes = pin.numframes;

            psprite = new msprite_t();
            psprite.frames = new mspriteframedesc_t[numframes];
            for(int kk = 0; kk < numframes; kk++)
                psprite.frames[kk] = new mspriteframedesc_t();

            mod.cache = psprite;

            psprite.type = pin.type;
            psprite.maxwidth = pin.width;
            psprite.maxheight = pin.height;
            psprite.beamlength = pin.beamlength;
            mod.synctype = pin.synctype;
            psprite.numframes = numframes;

            mod.mins[0] = mod.mins[1] = -psprite.maxwidth/2;
            mod.maxs[0] = mod.maxs[1] = psprite.maxwidth/2;
            mod.mins[2] = -psprite.maxheight/2;
            mod.maxs[2] = psprite.maxheight/2;

            //
            // load the frames
            //
            if (numframes < 1)
                sys_linux.Sys_Error ("Mod_LoadSpriteModel: Invalid # of frames: " + numframes + "\n");

            mod.numframes = numframes;
            mod.flags = 0;

            aux.ofs += sizeof_dsprite_t;

            for (i=0 ; i<numframes ; i++)
            {
                spriteframetype_t	frametype;

                pframetype = (dspriteframetype_t)aux;
                frametype = pframetype.type;
                psprite.frames[i].type = frametype;

                if (frametype == spriteframetype_t.SPR_SINGLE)
                {
                    aux.ofs += sizeof_dspriteframetype_t;
                    Mod_LoadSpriteFrame(aux, ref psprite.frames[i].frameptr);
                }
                else
                {
                    aux.ofs += sizeof_dspriteframetype_t;
                    Mod_LoadSpriteGroup(aux, ref psprite.frames[i].frameptr);
                }
            }

            mod.type = modtype_t.mod_sprite;
        }
Exemple #9
0
        /*
        =================
        Mod_LoadPlanes
        =================
        */
        static void Mod_LoadPlanes(bspfile.lump_t l)
        {
            int			        i, j;
            mplane_t[]	        @out;
            bspfile.dplane_t[]  @in;
            int			        count;
            int			        bits;

            if ((l.filelen % bspfile.sizeof_dplane_t) != 0)
                sys_linux.Sys_Error ("MOD_LoadBmodel: funny lump size in " + loadmodel.name);
            count = l.filelen / bspfile.sizeof_dplane_t;
            bspfile.ByteBuffer buf = new bspfile.ByteBuffer(mod_base, l.fileofs);
            @in = new bspfile.dplane_t[count];
            @out = new mplane_t[count];
            for (int kk = 0; kk < count; kk++)
            {
                @in[kk] = (bspfile.dplane_t)buf;
                buf.ofs += bspfile.sizeof_dplane_t;
                @out[kk] = new mplane_t();
            }

            loadmodel.planes = @out;
            loadmodel.numplanes = count;

            for ( i=0 ; i<count ; i++)
            {
                bits = 0;
                for (j=0 ; j<3 ; j++)
                {
                    @out[i].normal[j] = @in[i].normal[j];
                    if (@out[i].normal[j] < 0)
                        bits |= 1<<j;
                }

                @out[i].dist = @in[i].dist;
                @out[i].type = (byte)@in[i].type;
                @out[i].signbits = (byte)bits;
            }
        }
Exemple #10
0
        /*
        =================
        Mod_LoadNodes
        =================
        */
        static void Mod_LoadNodes(bspfile.lump_t l)
        {
            int			        i, j, count, p;
            bspfile.dnode_t[]   @in;
            mnode_t[] 	        @out;

            if ((l.filelen % bspfile.sizeof_dnode_t) != 0)
                sys_linux.Sys_Error ("MOD_LoadBmodel: funny lump size in " + loadmodel.name);
            count = l.filelen / bspfile.sizeof_dnode_t;
            bspfile.ByteBuffer buf = new bspfile.ByteBuffer(mod_base, l.fileofs);
            @in = new bspfile.dnode_t[count];
            @out = new mnode_t[count];
            for (int kk = 0; kk < count; kk++)
            {
                @in[kk] = (bspfile.dnode_t)buf;
                buf.ofs += bspfile.sizeof_dnode_t;
                @out[kk] = new mnode_t();
            }

            loadmodel.nodes = @out;
            loadmodel.numnodes = count;

            for ( i=0 ; i<count ; i++)
            {
                for (j=0 ; j<3 ; j++)
                {
                    @out[i].minmaxs[j] = @in[i].mins[j];
                    @out[i].minmaxs[3+j] = @in[i].maxs[j];
                }

                p = @in[i].planenum;
                @out[i].plane = loadmodel.planes[p];

                @out[i].firstsurface = @in[i].firstface;
                @out[i].numsurfaces = @in[i].numfaces;

                for (j=0 ; j<2 ; j++)
                {
                    p = @in[i].children[j];
                    if (p >= 0)
                        @out[i].children[j] = loadmodel.nodes[p];
                    else
                        @out[i].children[j] = loadmodel.leafs[-1 - p];
                }
            }

            Mod_SetParent (loadmodel.nodes[0], null);	// sets nodes and leafs
        }
Exemple #11
0
        /*
        =================
        Mod_LoadLeafs
        =================
        */
        static void Mod_LoadLeafs(bspfile.lump_t l)
        {
            bspfile.dleaf_t[] 	@in;
            mleaf_t[] 	        @out;
            int			        i, j, count, p;

            if ((l.filelen % bspfile.sizeof_dleaf_t) != 0)
                sys_linux.Sys_Error ("MOD_LoadBmodel: funny lump size in " + loadmodel.name);
            count = l.filelen / bspfile.sizeof_dleaf_t;
            bspfile.ByteBuffer buf = new bspfile.ByteBuffer(mod_base, l.fileofs);
            @in = new bspfile.dleaf_t[count];
            @out = new mleaf_t[count];
            for (int kk = 0; kk < count; kk++)
            {
                @in[kk] = (bspfile.dleaf_t)buf;
                buf.ofs += bspfile.sizeof_dleaf_t;
                @out[kk] = new mleaf_t();
            }

            loadmodel.leafs = @out;
            loadmodel.numleafs = count;

            for ( i=0 ; i<count ; i++)
            {
                for (j=0 ; j<3 ; j++)
                {
                    @out[i].minmaxs[j] = @in[i].mins[j];
                    @out[i].minmaxs[3+j] = @in[i].maxs[j];
                }

                p = @in[i].contents;
                @out[i].contents = p;

                @out[i].firstmarksurface = new helper.ObjectBuffer(loadmodel.marksurfaces, @in[i].firstmarksurface);
                @out[i].nummarksurfaces = @in[i].nummarksurfaces;

                p = @in[i].visofs;
                if (p == -1)
                    @out[i].compressed_vis = null;
                else
                    @out[i].compressed_vis = new bspfile.ByteBuffer(loadmodel.visdata, p);
                @out[i].efrags = null;

                for (j=0 ; j<4 ; j++)
                    @out[i].ambient_sound_level[j] = @in[i].ambient_level[j];
            }
        }
Exemple #12
0
        /*
        =================
        Mod_LoadClipnodes
        =================
        */
        private static void Mod_LoadClipnodes(bspfile.lump_t l)
        {
            bspfile.dclipnode_t[] @in, @out;
            int i, count;
            hull_t hull;

            if ((l.filelen % bspfile.sizeof_dclipnode_t) != 0)
                sys_linux.Sys_Error("MOD_LoadBmodel: funny lump size in " + loadmodel.name);
            count = l.filelen / bspfile.sizeof_dclipnode_t;
            bspfile.ByteBuffer buf = new bspfile.ByteBuffer(mod_base, l.fileofs);
            @in =  new bspfile.dclipnode_t[count];
            @out = new bspfile.dclipnode_t[count];
            for (int kk = 0; kk < count; kk++)
            {
                @in[kk] = (bspfile.dclipnode_t)buf;
                buf.ofs += bspfile.sizeof_dclipnode_t;
                @out[kk] = new bspfile.dclipnode_t();
            }

            loadmodel.clipnodes = @out;
            loadmodel.numclipnodes = count;

            hull = loadmodel.hulls[1];
            hull.clipnodes = @out;
            hull.firstclipnode = 0;
            hull.lastclipnode = count - 1;
            hull.planes = loadmodel.planes;
            hull.clip_mins[0] = -16;
            hull.clip_mins[1] = -16;
            hull.clip_mins[2] = -24;
            hull.clip_maxs[0] = 16;
            hull.clip_maxs[1] = 16;
            hull.clip_maxs[2] = 32;
            //Debug.WriteLine("@hull1 firstclipnode: " + hull.firstclipnode);

            hull = loadmodel.hulls[2];
            hull.clipnodes = @out;
            hull.firstclipnode = 0;
            hull.lastclipnode = count - 1;
            hull.planes = loadmodel.planes;
            hull.clip_mins[0] = -32;
            hull.clip_mins[1] = -32;
            hull.clip_mins[2] = -24;
            hull.clip_maxs[0] = 32;
            hull.clip_maxs[1] = 32;
            hull.clip_maxs[2] = 64;
            //Debug.WriteLine("@hull2 firstclipnode: "+ hull.firstclipnode);

            for (i = 0; i < count; i++)
            {
                @out[i].planenum = @in[i].planenum;
                @out[i].children[0] = @in[i].children[0];  //LittleShort
                @out[i].children[1] = @in[i].children[1];
                /*Debug.WriteLine(
                    string.Format(
                        " @planenum: {0}, @children[0]: {1}, @children[1]: {2}",
                        @in[i].planenum,
                        @in[i].children[0],
                        @in[i].children[1]));*/
            }
        }