Пример #1
0
    public override void SetMolecule(Molecule m, Vector3 pos)
    {
        Vector3 wPos = transform.TransformPoint(pos);

        MaterialZones.SolidMaterial check = MaterialZones.Check(wPos);
        if (check == MaterialZones.SolidMaterial.Flesh || check == MaterialZones.SolidMaterial.Epidermis)
        {
            Vector3 cellPos = MaterialZones.i.NearestTet(wPos, check == MaterialZones.SolidMaterial.Epidermis);
            float   angle   = Mathf.Atan2(wPos.z - cellPos.z, wPos.x - cellPos.x) * Mathf.Rad2Deg;
            if (angle < 0)
            {
                angle += 360;
            }
            Vector3i   cell    = new Vector3i(cellPos, MaterialZones.cellScaleRecip);
            LipidShell theCell = null; shells.TryGetValue(cell, out theCell);
            if (theCell == null)
            {
                //Debug.Log("adding (" + cell.x + ", " + cell.y + ", "+ cell.z +").   - "+ cellPos);
                theCell      = new LipidShell(numberOfSegments);
                shells[cell] = theCell;
            }
            float segAngle = angle * 0.00277777778f * (float)numberOfSegments;
            int   segId    = Mathf.FloorToInt(segAngle);
            if (theCell.segments[segId] < 1)
            {
                theCell.segments[segId]++;
                float   angleInc = ((float)segId) * numberOfSegmentsRecip * 360 * Mathf.Deg2Rad;
                Vector3 rVec     = new Vector3(Mathf.Cos(angleInc), 0, Mathf.Sin(angleInc));             //
                Vector3 lPos     = transform.InverseTransformPoint(cellPos + rVec * (MaterialZones.cellScale * 0.5f - MaterialZones.cellMembrane * 1.2f));
                m.Reset(lPos, Quaternion.LookRotation(Vector3.Cross(Vector3.up, rVec)), this, 0);
            }
        }
    }
Пример #2
0
    public void SetHelper(Vector3 pos)
    {
        MaterialZones.SolidMaterial check = MaterialZones.Check(pos);
        Vector3 wPos    = transform.TransformPoint(pos);
        Vector3 cellPos = MaterialZones.i.NearestTet(wPos, check == MaterialZones.SolidMaterial.Epidermis);
        float   angle   = Mathf.Atan2(wPos.z - cellPos.z, wPos.x - cellPos.x) * Mathf.Rad2Deg;

        if (angle < 0)
        {
            angle += 360;
        }
        Vector3i   cell    = new Vector3i(cellPos, MaterialZones.cellScaleRecip);
        LipidShell theCell = null; shells.TryGetValue(cell, out theCell);

        if (theCell == null)
        {
            //Debug.Log("adding (" + cell.x + ", " + cell.y + ", "+ cell.z +").   - "+ cellPos);
            theCell      = new LipidShell(numberOfSegments);
            shells[cell] = theCell;
        }
        float segAngle = angle * 0.00277777778f * (float)numberOfSegments;
        int   segId    = Mathf.FloorToInt(segAngle);

        if (theCell.segments[segId] < 1)
        {
            theCell.segments[segId]++;
        }
    }
Пример #3
0
    public override void SetMolecule(Molecule m, Vector3 pos)
    {
        MaterialZones.SolidMaterial check = MaterialZones.Check(transform.TransformPoint(pos));
        if (check == MaterialZones.SolidMaterial.Air)
        {
            float v = Random.value;
            if (v < 0.00039f)
            {
                m.Reset(pos, Quaternion.LookRotation(Random.onUnitSphere), this, 2);
            }
            else
            {
                /*if(v < 0.01039f) {
                 *      Molecules.currentDiatomic = Element.P;
                 * } else*/if (v < 0.21f)
                {
                    Molecules.currentDiatomic = Element.O;
                }
                else
                {
                    Molecules.currentDiatomic = Element.N;
                }
                m.Reset(pos, Quaternion.LookRotation(Random.onUnitSphere), this, 0);
            }
        }
        else if (check == MaterialZones.SolidMaterial.Soda)
        {
            float v = Random.value;
            if (v < 0.2f)
            {
                m.Reset(pos, Quaternion.LookRotation(Random.onUnitSphere), this, 3);
            }
        }
        else if (check == MaterialZones.SolidMaterial.Flesh || check == MaterialZones.SolidMaterial.Epidermis)
        {
            float v = Random.value;
            if (v < 0.05f)
            {
                m.Reset(pos, Quaternion.LookRotation(Random.onUnitSphere), this, 3);
            }
            else if (v < 0.4f)
            {
                m.Reset(pos, Quaternion.LookRotation(Random.onUnitSphere), this, 4);
            }
        }
        else if (check == MaterialZones.SolidMaterial.Chamber)
        {
            Atom[] list = new Atom[1];
            Atom   a    = new Atom();
            a.pos    = Vector3.zero;
            a.bonded = new int[0];
            a.e      = (Random.value > 0.5f) ? Element.O : Element.H;
            list[0]  = a;

            m.averagePos = Vector3.zero;
            m.Reset(pos, Quaternion.LookRotation(Random.onUnitSphere), this, list);
        }
    }
    public override void SetMolecule(Molecule m, Vector3 pos)
    {
        Vector3 wPos = transform.TransformPoint(pos);

        MaterialZones.SolidMaterial check = MaterialZones.Check(wPos);
        if ((liquid && (check == MaterialZones.SolidMaterial.Soda || ((check == MaterialZones.SolidMaterial.Flesh || check == MaterialZones.SolidMaterial.Epidermis) && !MaterialZones.i.CellwallArea(wPos, check)))) || (!liquid && check == MaterialZones.SolidMaterial.Steel))
        {
            Vector3 direction = pos * rotate;
            if (!liquid)
            {
                direction = new Vector3(0, (Mathf.Abs(direction.x) + Mathf.Abs(direction.y) + Mathf.Abs(direction.z)) * 0.3f, 0);
            }
            m.Reset(pos, Quaternion.Euler(direction), this, 0);
        }
    }
    public override void SetMolecule(Molecule m, Vector3 pos)
    {
        Vector3 p = transform.TransformPoint(pos);

        MaterialZones.SolidMaterial check = MaterialZones.Check(p);
        if (check == MaterialZones.SolidMaterial.Plastic && typeInstances[1])
        {
            Vector3 dir    = (cupTransform.position - p).normalized + Random.insideUnitSphere * 0.25f;
            Vector3 cross  = Vector3.Cross(Vector3.up, dir);
            Vector3 lookUp = cross * (Random.value - 0.5f) + Vector3.Cross(Vector3.up, cross) * (Random.value - 0.5f);
            m.Reset(pos - Vector3.up * 0.4f, Quaternion.LookRotation(dir, lookUp) * Quaternion.Euler(Random.value * 360, 0, 0), this, 1);
        }
        else if (check == MaterialZones.SolidMaterial.Wood && typeInstances[0])
        {
            Vector3 dir = woodTransform.forward + Random.insideUnitSphere * 0.4f;
            m.Reset(pos, Quaternion.LookRotation(dir) * Quaternion.Euler((Random.value - 0.5f) * 70 - 90, 90, 0), this, 0);
        }
    }
Пример #6
0
    public void SetCell(int x, int z, int y, bool always)
    {
        Vector3 p = SuddenlyTetrahedrons(x + position.x, y + position.y, z + position.z, false, false);

        MaterialZones.SolidMaterial check = MaterialZones.Check(transform.TransformPoint(p));
        if (((check != MaterialZones.SolidMaterial.Flesh && !epidermis) || (check != MaterialZones.SolidMaterial.Epidermis && epidermis)) && !always)
        {
            return;
        }

        int xRoll = (100000 + x + position.x) % ((int)tesselationDimensions.x - 1);
        int zRoll = (100000 + z + position.z) % ((int)tesselationDimensions.z - 1);

        //Debug.Log("cells["+cells.Length+"]"+ " ("+(x+position.x)+", "+(z+position.z)+")  ("+xRoll+", "+zRoll+", "+y+")");

        /*
         * if(xRoll < 0 || xRoll >= tesselationDimensions.x) {
         *      Debug.Log(xRoll);
         * }
         * if(zRoll < 0 || zRoll >= tesselationDimensions.z) {
         *      Debug.Log(zRoll);
         * }
         * if(y < 0 || y >= tesselationDimensions.y) {
         *      Debug.Log(y);
         * }
         */


        Cell c = cells[xRoll, zRoll, y];

        c.outsideRend.transform.localPosition = p;
        c.insideRend.transform.localPosition  = Random.insideUnitSphere * nucleusRand;
        if (epidermis)
        {
            c.outsideRend.transform.rotation = MaterialZones.skinRotation;
            c.outsideRend.material.SetColor("_Color", Color.Lerp(healthyColor1, deadColor1, MaterialZones.skinPosition));
            c.outsideRend.material.SetColor("_RimColor", Color.Lerp(healthyColor2, deadColor2, MaterialZones.skinPosition));
            c.outsideRend.material.SetColor("_RimColor1", Color.Lerp(healthyColor3, deadColor3, MaterialZones.skinPosition));
        }
    }
 void Awake()
 {
     i = this;
 }