public static VertexChannel GetTextureChannel(List<VertexChannel> channels, VertexChannelType channelIndex)
        {
            //it is valid, though rare, for a mesh to have no texture coordinates. in this case we will return position data in order that the triplets can be build efficiently.
            var fallback_channel = channels.Where(c => c.m_type == VertexChannelType.Positions).FirstOrDefault();

            //channel 1 is the default texture coordinate map channel
            var channel = channels.Where(c => c.m_type == VertexChannelType.Texture1).FirstOrDefault();

            if (channel != null)
            {
                fallback_channel = channel;
            }

            //now we have set up the fallbacks, search for the channel we actually want

            channel = channels.Where(c => c.m_type == (VertexChannelType)channelIndex).FirstOrDefault();

            if (channel == null)
            {
                channel = fallback_channel;

                //we will always search for up to two channels by default, and it will not be uncommon to only have one. If the user has requested a channel especially however
                //we should let them know.
                if ((int)channelIndex > 2)
                {
                    Debug.Log("Warning, could not find request channel number " + channelIndex);
                }
            }

            return channel;
        }
Exemplo n.º 2
0
 public virtual void Read(PackFileDeserializer des, BinaryReaderEx br)
 {
     m_name = des.ReadStringPointer(br);
     m_type = (VertexChannelType)br.ReadUInt32();
     br.ReadUInt32();
 }