protected byte[] CreateNormalVector3(RmvVector3 vector)
        {
            var output = new byte[4];

            output[0] = NormalToByte(vector.X);
            output[1] = NormalToByte(vector.Y);
            output[2] = NormalToByte(vector.Z);
            output[3] = NormalToByte(1);
            return(output);
        }
예제 #2
0
        public DefaultVertex(RmvVector4 position, RmvVector2 uv, RmvVector3 normal, RmvVector3 biNormal, RmvVector3 tanget)
        {
            _data = new Data()
            {
                position = CreatePositionVector4(position),
                uv       = CreatePositionVector2(uv),
                uvExtra  = CreatePositionVector2(new RmvVector2(0, 0)),
                normal   = CreateNormalVector3(normal),
                biNormal = CreateNormalVector3(biNormal),
                tangent  = CreateNormalVector3(tanget),
                RGBA     = new byte[4] {
                    0, 0, 0, 0
                }
            };

            CreateFromData(_data);
        }
예제 #3
0
        public WeightedVertex(RmvVector4 position, RmvVector2 uv, RmvVector3 normal, RmvVector3 biNormal, RmvVector3 tanget, BoneInformation[] boneInformation)
        {
            if (boneInformation.Length != 2)
            {
                throw new ArgumentException();
            }

            _data = new Data()
            {
                position   = CreatePositionVector4(position),
                uv         = CreatePositionVector2(uv),
                boneIndex  = boneInformation.Select(x => x.BoneIndex).ToArray(),
                boneWeight = boneInformation.Select(x => (byte)(x.BoneWeight * 255.0f)).ToArray(),
                normal     = CreateNormalVector3(normal),
                biNormal   = CreateNormalVector3(biNormal),
                tangent    = CreateNormalVector3(tanget),
            };

            CreateFromData(_data);
        }
        static Frame ReadFrame(ByteChunk chunk, uint positions, uint rotations)
        {
            var frame = new Frame();

            for (int j = 0; j < positions; j++)
            {
                var vector = new RmvVector3(chunk.ReadSingle(), chunk.ReadSingle(), chunk.ReadSingle());
                frame.Transforms.Add(vector);
            }

            for (int j = 0; j < rotations; j++)
            {
                var maxValue = 1.0f / (float)short.MaxValue;
                var quat     = new short[4] {
                    chunk.ReadShort(), chunk.ReadShort(), chunk.ReadShort(), chunk.ReadShort()
                };

                var quaternion = new RmvVector4(quat[0] * maxValue, quat[1] * maxValue, quat[2] * maxValue, quat[3] * maxValue);
                frame.Quaternion.Add(quaternion);
            }
            return(frame);
        }