コード例 #1
0
        private Vector ReadVectorXY(BitStream bitStream, DataTableProperty dataTableProperty)
        {
            Vector result = new Vector();

            result.X = ReadFloat(bitStream, dataTableProperty);
            result.Y = ReadFloat(bitStream, dataTableProperty);

            return result;
        }
コード例 #2
0
        private Vector ReadVector(BitStream bitStream, DataTableProperty dataTableProperty)
        {
            Vector result = new Vector();

            result.X = ReadFloat(bitStream, dataTableProperty);
            result.Y = ReadFloat(bitStream, dataTableProperty);

            if (!dataTableProperty.Flags.HasFlag(DataTablePropertyFlags.Normal))
            {
                result.Z = ReadFloat(bitStream, dataTableProperty);
            }
            else
            {
                bool isNegative = bitStream.ReadBit();

                float absolute = result.X * result.X + result.Y * result.Y;

                if (absolute < 1.0f)
                {
                    result.Z = (float)Math.Sqrt(1 - absolute);
                }
                else
                {
                    result.Z = 0f;
                }

                if (isNegative)
                {
                    result.Z *= -1;
                }
            }

            return result;
        }