示例#1
0
        /// <summary>
        /// Convert unity Vector3 to gltf Vector3
        /// </summary>
        /// <param name="unityVec3">unity Vector3</param>
        /// <returns>gltf Vector3</returns>
        public static GLTF.Math.Vector3 ToGltfVector3Convert(this Vector3 unityVec3)
        {
            Vector3 coordinateSpaceConversionScale = CoordinateSpaceConversionScale.ToUnityVector3Raw();

            GLTF.Math.Vector3 gltfVec3 = Vector3.Scale(unityVec3, coordinateSpaceConversionScale).ToGltfVector3Raw();
            return(gltfVec3);
        }
示例#2
0
 public KHR_materials_pbrSpecularGlossinessExtension(Color diffuseFactor, TextureInfo diffuseTexture, Vector3 specularFactor, double glossinessFactor, TextureInfo specularGlossinessTexture)
 {
     DiffuseFactor             = diffuseFactor;
     DiffuseTexture            = diffuseTexture;
     SpecularFactor            = specularFactor;
     GlossinessFactor          = glossinessFactor;
     SpecularGlossinessTexture = specularGlossinessTexture;
 }
示例#3
0
        /// <summary>
        /// Inverts the Z value of all Vector3s in an array to convert between glTF and Unity's coordinate systems.
        /// </summary>
        /// <param name="array">The array of Vector3s to be converted.</param>
        /// <returns>The array of converted Vector3s.</returns>
        public static GLTF.Math.Vector3[] FlipVectorArrayHandedness(GLTF.Math.Vector3[] array)
        {
            var returnArray = new GLTF.Math.Vector3[array.Length];

            for (var i = 0; i < array.Length; i++)
            {
                returnArray[i] = FlipVectorHandedness(array[i]);
            }

            return(returnArray);
        }
示例#4
0
 public static Vector3 ToUnityVector3(this GLTF.Math.Vector3 vec3)
 {
     return(new Vector3(vec3.X, vec3.Y, vec3.Z));
 }
示例#5
0
 /// <summary>
 /// Inverts the Z value of a Vector3 to convert between glTF and Unity's coordinate systems.
 /// </summary>
 /// <param name="vector">The Vector3 to be converted.</param>
 /// <returns>The converted Vector3.</returns>
 public static GLTF.Math.Vector3 FlipVectorHandedness(GLTF.Math.Vector3 vector)
 {
     return(new GLTF.Math.Vector3(vector.X, vector.Y, -vector.Z));
 }
示例#6
0
        /// <summary>
        /// Converts and copies based on the specified coordinate scale
        /// </summary>
        /// <param name="array">The array to convert and copy</param>
        /// <param name="coordinateSpaceCoordinateScale">The specified coordinate space</param>
        /// <returns>The copied and converted coordinate space</returns>
        public static UnityEngine.Vector3[] ConvertVector3CoordinateSpaceAndCopy(Vector3[] array, GLTF.Math.Vector3 coordinateSpaceCoordinateScale)
        {
            var returnArray = new UnityEngine.Vector3[array.Length];

            for (int i = 0; i < array.Length; i++)
            {
                returnArray[i].x = array[i].x * coordinateSpaceCoordinateScale.X;
                returnArray[i].y = array[i].y * coordinateSpaceCoordinateScale.Y;
                returnArray[i].z = array[i].z * coordinateSpaceCoordinateScale.Z;
            }

            return(returnArray);
        }
示例#7
0
 /// <summary>
 /// Converts vector3 to specified coordinate space
 /// </summary>
 /// <param name="attributeAccessor">The attribute accessor to modify</param>
 /// <param name="coordinateSpaceCoordinateScale">The coordinate space to move into</param>
 public static void ConvertVector3CoordinateSpace(ref AttributeAccessor attributeAccessor, GLTF.Math.Vector3 coordinateSpaceCoordinateScale)
 {
     for (int i = 0; i < attributeAccessor.AccessorContent.AsVertices.Length; i++)
     {
         attributeAccessor.AccessorContent.AsVertices[i].X *= coordinateSpaceCoordinateScale.X;
         attributeAccessor.AccessorContent.AsVertices[i].Y *= coordinateSpaceCoordinateScale.Y;
         attributeAccessor.AccessorContent.AsVertices[i].Z *= coordinateSpaceCoordinateScale.Z;
     }
 }
示例#8
0
 public static GLTF.Math.Vector3 ToGltfVector3Raw(this Vector3 unityVec3)
 {
     GLTF.Math.Vector3 gltfVec3 = new GLTF.Math.Vector3(unityVec3.x, unityVec3.y, unityVec3.z);
     return(gltfVec3);
 }
        public static UnityEngine.Vector3[] ConvertVector3CoordinateSpaceAndCopy1(Vector3[] array, GLTF.Math.Vector3 coordinateSpaceCoordinateScale)
        {
            var returnArray = new UnityEngine.Vector3[array.Length];

            for (int i = 0; i < array.Length; i++)
            {
                var vec    = array[i];
                var q      = Quaternion.Euler(new Vector3(90.0f, 0.0f, 0.0f));
                var newVec = q * vec;

                newVec.Normalize();
                returnArray[i].x = newVec.x * coordinateSpaceCoordinateScale.X;
                returnArray[i].y = newVec.y * coordinateSpaceCoordinateScale.Y;
                returnArray[i].z = newVec.z * coordinateSpaceCoordinateScale.Z;
            }

            return(returnArray);
        }