예제 #1
0
파일: ClipMap.cs 프로젝트: maesse/CubeHags
        /*
        ===================
        CM_InitBoxHull

        Set up the planes and nodes so that the six floats of a bounding box
        can just be stored out and get a proper clipping hull structure.
        ===================
        */
        void InitHullBox()
        {
            //box_planes =

            dbrush_t boxbrush = new dbrush_t();
            boxbrush.numsides = 6;
            boxbrush.contents = brushflags.CONTENTS_PLAYERCLIP;
            brushes.Add(boxbrush);
            box_brush = boxbrush;

            box_model = new cmodel_t();
            box_model.leaf = new dleaf_t();
            box_model.leaf.numleafbrushes = 1;
            box_model.leaf.firstleafbrush = (ushort)leafbrushes.Count;
            leafbrushes.Add(brushes.Count);

            cplane_t[] plan = new cplane_t[6*2];
            for (int i = 0; i < 12; i++)
            {
                plan[i] = new cplane_t();
            }

            dbrushside_t[] sides = new dbrushside_t[6];
            for (int i = 0; i < 6; i++)
            {
                sides[i] = new dbrushside_t();
            }

            int numBrushSides = brushsides.Count;
            for (int i = 0; i < 6; i++)
            {
                int side = i & 1;
                dbrushside_t s = sides[i];
                s.plane = plan[i * 2 + side];

                // planes
                cplane_t p = plan[i * 2];
                p.type = i >> 1;
                p.signbits = 0;
                p.normal = Vector3.Zero;
                p.normal[i >> 1] = 1;

                p = planes[i * 2 + 1];
                p.type = 3 + (i >> 1);
                p.signbits = 0;
                p.normal = Vector3.Zero;
                p.normal[i >> 1] = -1;

                Common.SetPlaneSignbits(p);
            }

            box_planes.AddRange(plan);
            planes.AddRange(plan);
            brushsides.AddRange(sides);
        }
예제 #2
0
        static void LoadModels(BinaryReader br, Header header)
        {
            // Models
            br.BaseStream.Seek(header.lumps[14].fileofs, SeekOrigin.Begin);
            int nModels = header.lumps[14].filelen / 48;
            dmodel_t[] models = new dmodel_t[nModels];
            for (int i = 0; i < nModels; i++)
            {
                dmodel_t model = new dmodel_t();
                model.mins = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
                model.maxs = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
                model.origin = SourceParser.SwapZY(new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()));
                model.headnode = br.ReadInt32();
                model.firstface = br.ReadInt32();
                model.numfaces = br.ReadInt32();
                models[i] = model;
            }

            world.cmodels = new cmodel_t[models.Length];

            for (int i = 0; i < models.Length; i++)
            {
                dmodel_t min = models[i];
                cmodel_t mout = new cmodel_t();
                mout.leaf = new dleaf_t();
                mout.mins = mout.maxs = Vector3.Zero;

                for (int j = 0; j < 3; j++)
                {
                    // spread the mins / maxs by a pixel
                    mout.mins[j] = min.mins[j] - 1;
                    mout.maxs[j] = min.maxs[j] + 1;
                }

                // world model doesn't need other info
                if (i == 0)
                    continue;

                mout.leaf.numleaffaces = (ushort)min.numfaces;
                mout.leaf.firstleafface = (ushort)world.leafFaces.Count;
                for (int j = 0; j < min.numfaces; j++)
                {
                    world.leafFaces.Add(min.firstface + j);
                }

                world.cmodels[i] = mout;
            }
        }
예제 #3
0
파일: ClipMap.cs 프로젝트: maesse/CubeHags
 public void ClearMap()
 {
     name = null;
     numBrushSides = 0;
     brushsides = new List<dbrushside_t>();
     planes = new List<cplane_t>();
     numNodes = 0;
     nodes = null;
     numLeafs = 0;
     leafs = null;
     numLeafBrushes = 0;
     leafbrushes = new List<int>();
     leafFaces = new List<int>();
     numSubModels = 0;
     cmodels = null;
     brushes = new List<dbrush_t>();
     numClusters = 0;
     clusterBytes = 0;
     visibility = null;
     vised = false;			// if false, visibility is just a single cluster of ffs
     entityString = null;
     numAreas = 0;
     numSurfaces = 0;
     floodvalid = 0;
     checkcount = 0;					// incremented on each trace
     c_traces = 0;
     c_brush_traces = 0;
     texinfos = null;
     box_model = new cmodel_t();
     box_planes = new List<cplane_t>();
     box_brush = new dbrush_t();
     vis = new dvis_t();
     edges  = null;
     DispIndexToFaceIndex  = null;
     ddispinfos  = null;
     dispLightmapSamples  = null;
     dispVerts  = null;
     dispTris  = null;
     dispCollTrees  = null;
     surfEdges = null;
 }