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); } } }
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]++; } }