Пример #1
0
    public bool applyFHN;     // R and t dependent


    // Start is called before the first frame update
    void DrawLens(LensData lens)
    {
        lensData = lens;
        int vertexCount = (int)(lens.H * 10);

        Vector3[]  positions = new Vector3[vertexCount];
        Keyframe[] widths    = new Keyframe[vertexCount];
        for (int i = 0; i < vertexCount; i++)
        {
            float normY   = 1.0f * i / (vertexCount - 1);
            float actualY = lens.H * (normY - 0.5f);
            positions[i] = new Vector3(actualY, 0, 0);
            widths[i]    = new Keyframe(normY, lens.GetWidthAt(actualY));
        }
        mechanical.positionCount = vertexCount;
        mechanical.SetPositions(positions);
        mechanical.widthCurve   = new AnimationCurve(widths);
        mechanical.startColor   = new Color(0, lens.invN * lens.invN, 1);
        mechanical.endColor     = mechanical.startColor;
        graphical.positionCount = vertexCount;
        graphical.SetPositions(positions);
        graphical.widthCurve = new AnimationCurve(widths);
        graphical.startColor = graphicalColor.Evaluate(lens.invN);
        graphical.endColor   = graphical.startColor;
    }
Пример #2
0
        public override void ReadFromFile(MemoryStream reader, bool isBigEndian)
        {
            base.ReadFromFile(reader, isBigEndian);
            numLens = reader.ReadInt32(isBigEndian);

            lens = new LensData[numLens];

            for (int i = 0; i != numLens; i++)
            {
                lens[i] = new LensData(reader, isBigEndian);
            }
        }
Пример #3
0
 void Update()
 {
     // For some reason +1 to focal length works well. :/
     if (applyFHT)
     {
         DrawLens(LensData.fHt(spec.x + 1, spec.y, spec.z));
         applyFHT = false;
     }
     if (applyFHN)
     {
         DrawLens(LensData.fHn(spec.x + 1, spec.y, spec.z));
         applyFHN = false;
     }
 }
Пример #4
0
        private static LensData ParseLensCorrection(byte[] buffer, ulong offset)
        {
            LensData data = new LensData();

            data.LensId         = GetUInt16(buffer, offset + 0x00);
            data.Unknown2       = GetUInt16(buffer, offset + 0x02);
            data.FocalLengthMin = GetUInt16(buffer, offset + 0x04);
            data.FocalLengthMax = GetUInt16(buffer, offset + 0x06);
            data.FocusDistMin   = GetUInt16(buffer, offset + 0x08);

            if (data.FocalLengthMax != data.FocalLengthMin)
            {
                Log.WriteLine("    Parsing lens {0}-{1} mm (min focus {2} mm) lens data [{3}, {4}]", data.FocalLengthMin, data.FocalLengthMax, data.FocusDistMin, data.LensId, data.Unknown2);
            }
            else
            {
                Log.WriteLine("    Parsing lens {0} mm (min focus {2} mm) lens data [{3}, {4}]", data.FocalLengthMin, data.FocalLengthMax, data.FocusDistMin, data.LensId, data.Unknown2);
            }

            /* this header */
            offset += 0x20;

            Log.WriteLine("      Reading profile type A");
            data.ProfileTypesA = ParseLensCorrectionTypeA(buffer, ref offset);
            if (GetUInt32(buffer, offset) != 0x44444444)
            {
                Log.WriteLine("      [E] End token at offset 0x{0:X8} is not 0x44444444", offset);
                return(null);
            }
            offset += 0x04;
            Log.WriteLine("      Reading profile type B");
            data.ProfileTypesB = ParseLensCorrectionTypeB(buffer, ref offset);
            if (GetUInt32(buffer, offset) != 0x33333333)
            {
                Log.WriteLine("      [E] End token at offset 0x{0:X8} is not 0x33333333", offset);
                return(null);
            }
            offset += 0x04;
            Log.WriteLine("      Reading profile type C");
            data.ProfileTypesC = ParseLensCorrectionTypeC(buffer, ref offset);
            if (GetUInt32(buffer, offset) != 0x22222222)
            {
                Log.WriteLine("      [E] End token at offset 0x{0:X8} is not 0x22222222", offset);
                return(null);
            }

            return(data);
        }
Пример #5
0
        private static LensData ParseLensCorrection(byte[] buffer, ulong offset)
        {
            LensData data = new LensData();

            data.LensId = GetUInt16(buffer, offset + 0x00);
            data.Unknown2 = GetUInt16(buffer, offset + 0x02);
            data.FocalLengthMin = GetUInt16(buffer, offset + 0x04);
            data.FocalLengthMax = GetUInt16(buffer, offset + 0x06);
            data.FocusDistMin = GetUInt16(buffer, offset + 0x08);

            if (data.FocalLengthMax != data.FocalLengthMin)
            {
                Log.WriteLine("    Parsing lens {0}-{1} mm (min focus {2} mm) lens data [{3}, {4}]", data.FocalLengthMin, data.FocalLengthMax, data.FocusDistMin, data.LensId, data.Unknown2);
            }
            else
            {
                Log.WriteLine("    Parsing lens {0} mm (min focus {2} mm) lens data [{3}, {4}]", data.FocalLengthMin, data.FocalLengthMax, data.FocusDistMin, data.LensId, data.Unknown2);
            }

            /* this header */
            offset += 0x20;

            Log.WriteLine("      Reading profile type A");
            data.ProfileTypesA = ParseLensCorrectionTypeA(buffer, ref offset);
            if (GetUInt32(buffer, offset) != 0x44444444)
            {
                Log.WriteLine("      [E] End token at offset 0x{0:X8} is not 0x44444444", offset);
                return null;
            }
            offset += 0x04;
            Log.WriteLine("      Reading profile type B");
            data.ProfileTypesB = ParseLensCorrectionTypeB(buffer, ref offset);
            if (GetUInt32(buffer, offset) != 0x33333333)
            {
                Log.WriteLine("      [E] End token at offset 0x{0:X8} is not 0x33333333", offset);
                return null;
            }
            offset += 0x04;
            Log.WriteLine("      Reading profile type C");
            data.ProfileTypesC = ParseLensCorrectionTypeC(buffer, ref offset);
            if (GetUInt32(buffer, offset) != 0x22222222)
            {
                Log.WriteLine("      [E] End token at offset 0x{0:X8} is not 0x22222222", offset);
                return null;
            }

            return data;
        }