Ejemplo n.º 1
0
        public int[] GetLongIndexData()
        {
            var        inds      = Engine_Faces.SelectMany(o => o.EngTriangles).Count() * 3;
            List <int> indpoints = new List <int>();

            for (int ni = 0; ni < inds; ni++)
            {
                indpoints.Add(ni);
            }
            return(indpoints.ToArray());
        }
Ejemplo n.º 2
0
        public short[] GetShortIndex()
        {
            var          inds      = Engine_Faces.SelectMany(o => o.EngTriangles).Count() * 3;
            List <short> indpoints = new List <short>();

            for (short ni = 0; ni < inds; ni++)
            {
                indpoints.Add(ni);
            }
            return(indpoints.ToArray());
        }
Ejemplo n.º 3
0
        internal bool GenerateTangents()
        {
            Logger.Log("Generating Tangents");
            UseLargeIndex = true;
            var vbPoints        = GetVbArray();
            var IndexData       = GetLongIndexData();
            var tangentPosition = TangentStart();
            var vbSize          = GetVBSize();

            if (IndexData == null)
            {
                Logger.Log($"Maximum Limits Reached for this Model {Name}");
                return(false);
            }

            Urho3D.GenerateTangents(vbPoints, vbSize, IndexData, IndexSize(), 0, IndexData.Length, tangentPosition);

            var ps         = vbPoints.ToList();
            var facescount = Engine_Faces.Count;
            var pointSize  = Engine_Faces[0].EngTriangles[0].V1.GetSize();
            var triangles  = Engine_Faces.SelectMany(o => o.EngTriangles).ToList();

            foreach (var engTriangle in triangles)
            {
                var triIndex   = triangles.IndexOf(engTriangle);
                int rangestart = triIndex * 3 * pointSize;
                var range      = ps.GetRange(rangestart, 3 * pointSize);

                for (int rangeIndex = 0; rangeIndex < range.Count; rangeIndex++)
                {
                    var triPoints = engTriangle.GetPoints();
                    foreach (var engPoint in triPoints)
                    {
                        engPoint.EngTangent.X = range[tangentPosition];
                        engPoint.EngTangent.Y = range[tangentPosition + 1];
                        engPoint.EngTangent.Z = range[tangentPosition + 2];
                        engPoint.EngTangent.L = range[tangentPosition + 3];
                    }
                }
            }

            return(true);
        }