예제 #1
0
 public void LoadModel0()
 {
     BSPFileParser.Model m = _models [0];
     bool[] temp           = new bool[m.face + m.n_faces];
     for (int i = m.face; i < m.face + m.n_faces; i++)
     {
         temp[i] = true;
     }
     RefreshObjects(temp, m.face, m.n_faces);
 }
예제 #2
0
    public void LoadModels0()
    {
        LoadMesh();
        BSPFileParser.Model m    = _models [0];
        ArrayList           temp = new ArrayList();

        for (int i = m.face; i < m.face + m.n_faces; i++)
        {
            temp.Add(i);
        }
        LoadTriangles(temp);
    }
예제 #3
0
    public void LoadVisibleModel0(Camera cam)
    {
        ArrayList visibleLeafs = findVisibleLeafs(cam);
        ArrayList visibleFaces = findVisibleFaces(visibleLeafs);

        visibleFaces = backfaceCulling(cam, visibleFaces);
        BSPFileParser.Model m = _models [0];
        bool[] temp           = new bool[m.face + m.n_faces];
        for (int i = 0; i < visibleFaces.Count; i++)
        {
            temp[(int)visibleFaces[i]] = true;
        }
        LoadObjects(temp, m.face, m.n_faces);
    }
예제 #4
0
    public void LoadVisibleModel0(Camera cam)
    {
        ArrayList visibleLeafs = findVisibleLeafs(cam);
        ArrayList visibleFaces = findVisibleFaces(visibleLeafs);

        // Cannot back culling, If back face is droped,
        // the mesh collider generate from the back face will be droped too
        //visibleFaces = backfaceCulling (cam, visibleFaces);
        BSPFileParser.Model m = _models [0];
        bool[] temp           = new bool[m.face + m.n_faces];
        for (int i = 0; i < visibleFaces.Count; i++)
        {
            temp[(int)visibleFaces[i]] = true;
        }
        RefreshObjects(temp, m.face, m.n_faces);
    }
예제 #5
0
    // Load all of meshes to construct game objects
    // and as children be add to gmObject
    void LoadAllMeshAndObject(GameObject gmObject, BSPFileParser.Model m, string childName)
    {
        gmObject.transform.DetachChildren();

        meshes  = new UnityEngine.Mesh[m.face + m.n_faces];
        objects = new UnityEngine.GameObject[m.face + m.n_faces];
        for (int faceIndex = m.face; faceIndex < m.face + m.n_faces; faceIndex++)
        {
            BSPFileParser.Face f = _faces [faceIndex];

            // Construct Mesh
            UnityEngine.Mesh mesh = new UnityEngine.Mesh();
            mesh.vertices = vertices;
            mesh.normals  = normals;
            mesh.uv       = uvs;
            mesh.uv2      = uv2s;
            mesh.colors   = colors;
            int[] triangles = new int[f.n_meshverts];
            for (int j = f.meshvert; j < f.meshvert + f.n_meshverts; j++)
            {
                triangles[j - f.meshvert] = f.vertex + _meshverts[j];
            }
            mesh.triangles = triangles;

            // Construct GameObject
            GameObject childObject = new GameObject(childName);
            childObject.AddComponent <MeshFilter>().mesh       = mesh;
            childObject.AddComponent <MeshRenderer>().material = _materials[f.texture];

            if (colliderType == ModelColliderType.MeshCollider)
            {
                childObject.AddComponent <MeshCollider>().sharedMesh = mesh;
            }

            childObject.transform.SetParent(gmObject.transform);

            meshes[faceIndex]  = mesh;
            objects[faceIndex] = childObject;
        }

        if (colliderType == ModelColliderType.BoxCollider)
        {
            LoadCollider(gmObject);
        }
    }