Exemplo n.º 1
0
        /// <summary>
        /// Helper function, returns the p[] value for the given index
        /// </summary>
        /// <param name="input">The "<input>" element we need the index of.</param>
        /// <param name="primitive">The "<primitive>" element the "<input>" is from.</param>
        /// <param name="index"> The index for which we need the p[] value.</param>
        static public int GetPValue(Document.Input input, Document.Primitive primitive, int index)
        {
            int stride = primitive.stride;
            int offset = input.offset;

            return(primitive.p[index * stride + offset]);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Helper function. Returns all the inputs of the primitive.
        /// Resolve the 'VERTEX' indirection case.
        /// <param name="doc">The COLLADA document</param>
        /// <param name="primitive"> The "<primitive>" we need the inputs from.</param>
        /// </summary>
        static public List <Document.Input> getAllInputs(Document doc, Document.Primitive primitive)
        {
            List <Document.Input> inputs = new List <Document.Input>();

            Document.Input vertexInput = null;

            // 1- get all the regular inputs
            foreach (Document.Input input in primitive.Inputs)
            {
                if (input.semantic == "VERTEX")
                {
                    vertexInput = input;
                }
                else
                {
                    inputs.Add(new Document.Input(doc, input.offset, input.semantic, input.set, ((Document.Source)input.source).id));
                }
            }
            // 2- get all the indirect inputs
            if (vertexInput != null)
            {
                foreach (Document.Input input in ((Document.Vertices)vertexInput.source).inputs)
                {
                    inputs.Add(new Document.Input(doc, vertexInput.offset, input.semantic, input.set, ((Document.Source)input.source).id));
                }
            }
            return(inputs);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Helper function. Returns inputs with specified semantic for specified primitive.
        /// Resolves the 'VERTEX' indirection case.
        /// </summary>
        /// <param name="primitive">The "<primitive>" we need the inputs from.</param>
        /// <param name="semantic">The semantic the inputs should have.</param>
        public static List <Document.Input> GetInput(Document.Primitive primitive, string semantic)
        {
            List <Document.Input> resultList = new List <Document.Input>();
            List <Document.Input> inputs     = GetAllInputs(primitive);

            foreach (Document.Input input in inputs)
            {
                if (input.semantic == semantic)
                {
                    resultList.Add(input);
                }
            }
            return(resultList);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Helper function. Returns all the inputs of the primitive.
        /// Resolve the 'VERTEX' indirection case.
        /// <param name="doc">The COLLADA document</param>
        /// <param name="primitive"> The "<primitive>" we need the inputs from.</param>
        /// </summary>
        public static List <Document.Input> GetAllInputs(Document.Primitive primitive)
        {
            List <Document.Input> inputs = new List <Document.Input>();

            // 1- get all the regular inputs
            foreach (Document.Input input in primitive.Inputs)
            {
                if (input.semantic == "VERTEX")
                {
                    // 2- get all the indirect inputs
                    foreach (Document.Input input2 in ((Document.Vertices)input.source).inputs)
                    {
                        inputs.Add(new Document.Input(input2.doc, input.offset, input2.semantic, input2.set, ((Document.Source)input2.source).id));
                    }
                }
                else
                {
                    inputs.Add(input);
                }
            }

            return(inputs);
        }