Exemplo n.º 1
0
        private static BVHChannels[] ReadChannels(StreamReader reader)
        {
            string line = reader.ReadLine().ToLower().Trim();

            string[] tokens = line.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);

            if (tokens[0] != "channels")
            {
                throw new FileFormatException("Expected CHANNELS keyword");
            }

            int numChannels = Int32.Parse(tokens[1]);

            if (tokens.Length != numChannels + 2)
            {
                throw new FileFormatException(
                          $"Invalid CHANNELs Definition: {numChannels} expected, but {tokens.Length - 2} found");
            }

            BVHChannels[] channels = new BVHChannels[numChannels];
            for (int i = 0; i < numChannels; i++)
            {
                if (!Enum.TryParse <BVHChannels>(tokens[i + 2], true, out channels[i]))
                {
                    throw new FileFormatException($"Invalid channel: {tokens[i + 2]}");
                }
            }

            return(channels);
        }
Exemplo n.º 2
0
        private static Vector3D GetAxisFromChannelType(BVHChannels channel)
        {
            switch (channel)
            {
            case BVHChannels.Xrotation:
                return(new Vector3D(1, 0, 0));

            case BVHChannels.Yrotation:
                return(new Vector3D(0, 1, 0));

            case BVHChannels.Zrotation:
                return(new Vector3D(0, 0, 1));

            default:
                throw new InvalidOperationException($"Channel type {channel} not supported");
            }
        }