示例#1
0
        public static bool GenerateTangentSpace(int faceCount, VerticesPerFaceHandler getVerticesPerFace,
                                                VertexPositionHandler getPosition, VertexNormalHandler getNormal, VertexUVHandler getUV,
                                                BasicTangentHandler setTangentBasic, float angularThreshold = 180)
        {
            var context = new MikktspaceContext(faceCount, getVerticesPerFace, getPosition, getNormal, getUV,
                                                setTangentBasic, null);

            return(GenerateTangentSpace(context, angularThreshold));
        }
示例#2
0
        public MikktspaceContext(int faceCount, VerticesPerFaceHandler getVerticesPerFace,
                                 VertexPositionHandler getVertexPosition, VertexNormalHandler getVertexNormal, VertexUVHandler getVertexUV,
                                 BasicTangentHandler setTangentBasic = null, TangentHandler setTangent = null)
        {
            if (faceCount <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(faceCount), "Face Count must be larger than 0");
            }

            if (getVerticesPerFace == null)
            {
                throw new ArgumentNullException(nameof(getVerticesPerFace), "All mesh data callbacks must be provided");
            }

            if (getVertexNormal == null)
            {
                throw new ArgumentNullException(nameof(getVerticesPerFace), "All mesh data callbacks must be provided");
            }

            if (getVertexUV == null)
            {
                throw new ArgumentNullException(nameof(getVerticesPerFace), "All mesh data callbacks must be provided");
            }

            if (setTangentBasic == null && setTangent == null)
            {
                throw new ArgumentException($"Both {nameof(setTangentBasic)} and {nameof(setTangent)} are null");
            }

            if (setTangentBasic != null && setTangent != null)
            {
                throw new ArgumentException($"{nameof(setTangentBasic)} and {nameof(setTangent)} cannot be used at the same time");
            }

            this.FaceCount          = faceCount;
            this.GetVerticesPerFace = getVerticesPerFace;

            this.GetVertexPosition = getVertexPosition;
            this.GetVertexNormal   = getVertexNormal;
            this.GetVertexUV       = getVertexUV;

            this.SetTangentBasic = setTangentBasic;
            this.SetTangent      = setTangent;
        }