当前位置: 首页>>代码示例>>C#>>正文


C# Transform.Apply方法代码示例

本文整理汇总了C#中Transform.Apply方法的典型用法代码示例。如果您正苦于以下问题:C# Transform.Apply方法的具体用法?C# Transform.Apply怎么用?C# Transform.Apply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Transform的用法示例。


在下文中一共展示了Transform.Apply方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TriangleMesh

        public TriangleMesh(Transform objectToWorld, Transform worldToObject, bool ro, int ntris, int nverts, int[] vptr, Point[] p, Normal[] n, Vector[] s, double[] uv,
        ITexture<double> atex)
            : base(objectToWorld, worldToObject, ro)
        {
            NumberOfTriangles = ntris;
            NumberOfVertices = nverts;
            AlphaTexture = atex;

            /*VertexIndices = new int[3 * NumberOfTriangles];
            vptr.CopyTo (VertexIndices, 0);*/
            VertexIndices = vptr;

            /*if (uv != null)
            {
                Uvs = new double[2 * NumberOfVertices];
                uv.CopyTo (Uvs, 0);
            }
            else
                Uvs = null;*/

            Points = new Point[NumberOfVertices];
            Normals = n;
            Vectors = s;
            Uvs = uv;

            /*if (n != null)
            {
                Normals = new Normal[NumberOfVertices];
                n.CopyTo (Normals, 0);
            }
            else
                Normals = null;

            if (s != null)
            {
                Vectors = new Vector[NumberOfVertices];
                s.CopyTo (Vectors, 0);
            }
            else
                Vectors = null;*/

            for (int i = 0; i < NumberOfVertices; ++i)
                Points[i] = objectToWorld.Apply (p[i]);
        }
开发者ID:Kintaro,项目名称:Hyperion,代码行数:44,代码来源:TriangleMesh.cs

示例2: Apply

 public void Apply(Ray r, ref Ray tr)
 {
     if (!ActuallyAnimated || r.Time <= StartTime)
         StartTransform.Apply (r, ref tr);
     else if (r.Time >= EndTime)
         EndTransform.Apply (r, ref tr);
     else
     {
         Transform t = new Transform ();
         Interpolate (r.Time, ref t);
         t.Apply (r, ref tr);
     }
     tr.Time = r.Time;
 }
开发者ID:Kintaro,项目名称:Hyperion,代码行数:14,代码来源:AnimatedTransform.cs

示例3: GetShadingGeometry

        public override void GetShadingGeometry(Transform objectToWorld, DifferentialGeometry dg, ref DifferentialGeometry dgShading)
        {
            if (Mesh.Normals == null && Mesh.Vectors == null)
            {
                dgShading = new DifferentialGeometry (dg);
                return;
            }
            // Initialize _Triangle_ shading geometry with _n_ and _s_
            // Compute barycentric coordinates for point
            double[] b = new double[3];

            // Initialize _A_ and _C_ matrices for barycentrics
            double[] uv = new double[6];
            GetUVs (uv);
            double[][] A = new double[][] { new double[] { uv[2] - uv[0], uv[4] - uv[0] }, new double[] { uv[3] - uv[1], uv[5] - uv[1] } };
            double[] C = new double[] { dg.u - uv[0], dg.v - uv[1] };
            if (!Util.SolveLinearSystem2x2 (A, C[0], C[1], out b[1], out b[2]))
            {
                // Handle degenerate parametric mapping
                b[0] = b[1] = b[2] = 1.0 / 3.0;
            } else
                b[0] = 1.0 - b[1] - b[2];

            // Use _n_ and _s_ to compute shading tangents for triangle, _ss_ and _ts_
            Normal ns;
            Vector ss, ts;
            if (Mesh.Normals != null)
                ns = objectToWorld.Apply (b[0] * Mesh.Normals[Vertices[0]] +
                    b[1] * Mesh.Normals[Vertices[1]] +
                    b[2] * Mesh.Normals[Vertices[2]]).Normalized;
            else
                ns = new Normal (dg.n);
            if (Mesh.Vectors != null)
                ss = objectToWorld.Apply (b[0] * Mesh.Vectors[Vertices[0]] +
                    b[1] * Mesh.Vectors[Vertices[1]] +
                    b[2] * Mesh.Vectors[Vertices[2]]).Normalized;
            else
                ss = dg.dpdu.Normalized;
            ts = ss % ns;
            if (ts.SquaredLength > 0.0)
            {
                ts = ts.Normalized;
                ss = ts % ns;
            } else
                Util.CoordinateSystem (new Vector (ns), out ss, out ts);
            Normal dndu, dndv;

            // Compute $\dndu$ and $\dndv$ for triangle shading geometry
            if (Mesh.Normals != null)
            {
                double[] uvs = new double[6];
                GetUVs (uvs);
                // Compute deltas for triangle partial derivatives of normal
                double du1 = uvs[0] - uvs[4];
                double du2 = uvs[2] - uvs[4];
                double dv1 = uvs[1] - uvs[5];
                double dv2 = uvs[3] - uvs[5];
                Normal dn1 = Mesh.Normals[Vertices[0]] - Mesh.Normals[Vertices[2]];
                Normal dn2 = Mesh.Normals[Vertices[1]] - Mesh.Normals[Vertices[2]];
                double determinant = du1 * dv2 - dv1 * du2;
                if (determinant == 0.0)
                {
                    dndu = new Normal (0, 0, 0);
                    dndv = new Normal (0, 0, 0);
                } else
                {
                    double invdet = 1.0 / determinant;
                    dndu = (dv2 * dn1 - dv1 * dn2) * invdet;
                    dndv = (-du2 * dn1 + du1 * dn2) * invdet;
                }
            } else
            {
                dndu = new Normal (0, 0, 0);
                dndv = new Normal (0, 0, 0);
            }
            dgShading = new DifferentialGeometry (dg.p, ss, ts, ObjectToWorld.Apply (dndu), ObjectToWorld.Apply (dndv), dg.u, dg.v, dg.Shape);
            dgShading.dudx = dg.dudx;
            dgShading.dvdx = dg.dvdx;
            dgShading.dudy = dg.dudy;
            dgShading.dvdy = dg.dvdy;
            dgShading.dpdx = new Vector (dg.dpdx);
            dgShading.dpdy = new Vector (dg.dpdy);
        }
开发者ID:Kintaro,项目名称:Hyperion,代码行数:83,代码来源:Triangle.cs


注:本文中的Transform.Apply方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。