Exemplo n.º 1
0
        public void Start()
        {
            //example of referencing a script attached to another component:
            //dnaPlaneController = (DNAPlaneController) DNA_Plane.GetComponent(typeof(DNAPlaneController));
            loadBox = GameObject.Find("LoadBox");
            scene   = (ScenePreload_5L1B)loadBox.GetComponent(typeof(ScenePreload_5L1B));

            if (loadBox == null)
            {
                Debug.Log("loadBox is null");
            }
            if (scene == null)
            {
                Debug.Log("scene is null");
            }
        }
Exemplo n.º 2
0
    //@imyjimmy proof of concept of adding/ changing the mesh.
    public void updateSplit(int resNum)
    {
        if (scenePreload == null)
        {
            scenePreload = (ScenePreload_5L1B)LoadBox.GetComponent(typeof(ScenePreload_5L1B));
        }

        hlResMat = scenePreload.hlResMat;

        float x = 0.0f; float y = 0.0f; float z = 0.0f;

        // oldUpdateSplit(resNum);
        Debug.Log("the residue number: " + resNum + " residueSeq.Count: " + residueSeq.Count);

        Residue r = residueSeq[resNum];

        Debug.Log("vertices: " + r.vertices);
        Debug.Log("updatesplit: r.vertices.Length: " + r.vertices.Count);
        foreach (int s in r.vertices)
        {
            Debug.Log("s: " + meshes[0].vertices[s]);
        }
        int beginV = r.vertices[0];
        int endV   = r.vertices[1];

        if (r.vertices.Count > 2)
        {
            //hold that thought for now
        }

        float maxX = float.MinValue, maxY = float.MinValue, maxZ = float.MinValue;
        float y_MaxX = 0.0f, z_MaxX = 0.0f, x_MaxY = 0.0f, z_MaxY = 0.0f, x_MaxZ = 0.0f, y_MaxZ = 0.0f;

        float minX = float.MaxValue, minY = float.MaxValue, minZ = float.MaxValue;
        float y_MinX = 0.0f, z_MinX = 0.0f, x_MinY = 0.0f, z_MinY = 0.0f, x_MinZ = 0.0f, y_MinZ = 0.0f;

        // foreach (int mIndex in r.meshIndices) { //consodering meshindices of length 1 for now.
        int  mIndex = 0;
        Mesh m      = meshes[mIndex];
        int  count  = endV - beginV + 1;

        for (int vInt = beginV; vInt <= endV; vInt++)
        {
            Vector3 v = pp.gameObjects[mIndex].transform.TransformPoint(m.vertices[vInt]);
            x += v.x;
            if (v.x > maxX)
            {
                maxX   = v.x;
                y_MaxX = v.y;
                z_MaxX = v.z;
            }

            if (v.x < minX)
            {
                minX   = v.x;
                y_MinX = v.y;
                z_MinX = v.z;
            }

            y += v.y;
            if (v.y > maxY)
            {
                maxY   = v.y;
                x_MaxY = v.x;
                z_MaxY = v.z;
            }

            if (v.y < minY)
            {
                minY   = v.y;
                x_MinY = v.x;
                z_MinY = v.z;
            }

            z += v.z;
            if (v.z > maxZ)
            {
                maxZ   = v.z;
                x_MaxZ = v.x;
                y_MaxZ = v.y;
            }
            if (v.z < minZ)
            {
                minZ   = v.z;
                x_MinZ = v.x;
                y_MinZ = v.y;
            }
        }
        // }

        // Debug.Log("x: " + maxX + "," + minX + " y: " + maxY + "," + minY + " z: " + maxZ + "," + minZ +
        //  "\nx: " + x + " y: " + y + " z: " + z + " count: " + count);
        Vector3 avgCoord = new Vector3(x / (float)count, y / (float)count, z / (float)count);

        // Debug.Log("updating split, avgCoord: " + avgCoord);
        avgCoord = LoadBox.transform.TransformPoint(avgCoord);
        // Debug.Log("after transform.TransformPoint, avgCoord: " + avgCoord);

        Mesh focusMesh = diamond(new Vector3(maxX, y_MaxX, z_MaxX), new Vector3(x_MaxY, maxY, z_MaxY), new Vector3(x_MaxZ, y_MaxZ, maxZ),
                                 new Vector3(minX, y_MinX, z_MinX), new Vector3(x_MinY, minY, z_MinY), new Vector3(x_MinZ, y_MinZ, minZ), avgCoord);

        ProteinFocus = new GameObject("ProteinFocus");
        ProteinFocus.transform.parent        = LoadBox.transform;
        ProteinFocus.transform.localPosition = avgCoord;
        ProteinFocus.AddComponent <MeshFilter>();
        ProteinFocus.AddComponent <MeshRenderer>();

        // Material material = ProteinFocus.GetComponent<Renderer>().material;
        // ProteinFocus.GetComponent<Renderer>().material = hlResMat;
        ProteinFocus.GetComponent <Renderer>().material = new Material(Shader.Find("Outlined/Silhouetted Diffuse"));
        var texture = new Texture2D(100, 100, TextureFormat.BGRA32, true);

        ProteinFocus.GetComponent <Renderer>().material.mainTexture = texture;

        texture.filterMode = FilterMode.Point;
        texture.Apply();

        ProteinFocus.GetComponent <MeshFilter>().mesh = focusMesh;

        // Vector3 worldAvgCoord = transform.TransformPoint(avgCoord);
        // ProteinFocus.transform.position = avgCoord;
        // ProteinFocus.transform.localScale *= 1.2f;
        ProteinFocus.tag = "RibbonObj";

        ProteinFocus.transform.localPosition = LoadBox.transform.localPosition;
    }