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


C# AABB.GetTransform方法代码示例

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


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

示例1: Draw

        public void Draw(ImageCloud.FreeView freeview, AABB selectionAabb, Color4 selectionAabbColor, Size backbuffersize, int numdims = 3)
        {
            /*// Use custom projection matrix with z-far tailored to include all axes
            float maxdist = 0.0f;
            maxdist = Math.Max(maxdist, (new Vector3(1000.0f, 0.0f, 0.0f) - freeview.viewpos).Length);
            maxdist = Math.Max(maxdist, (new Vector3(-1000.0f, 0.0f, 0.0f) - freeview.viewpos).Length);
            maxdist = Math.Max(maxdist, (new Vector3(0.0f, 1000.0f, 0.0f) - freeview.viewpos).Length);
            maxdist = Math.Max(maxdist, (new Vector3(0.0f, -1000.0f, 0.0f) - freeview.viewpos).Length);
            maxdist = Math.Max(maxdist, (new Vector3(0.0f, 0.0f, 1000.0f) - freeview.viewpos).Length);
            maxdist = Math.Max(maxdist, (new Vector3(0.0f, 0.0f, -1000.0f) - freeview.viewpos).Length);
            Matrix4 viewprojmatrix = freeview.viewmatrix * Matrix4.CreatePerspectiveFieldOfView(ImageCloud.FOV_Y, (float)backbuffersize.Width / (float)backbuffersize.Height, maxdist / 10000.0f, maxdist);*/
            Matrix4 viewprojmatrix = freeview.viewprojmatrix;

            Vector3 __axis_dist = new Vector3((new Vector2(freeview.viewpos.Y, freeview.viewpos.Z)).Length,
                                            (new Vector2(freeview.viewpos.X, freeview.viewpos.Z)).Length,
                                            (new Vector2(freeview.viewpos.X, freeview.viewpos.Y)).Length);
            Vector3 axis_dist = new Vector3(), _axis_dist = new Vector3();
            for(int i = 0; i < numdims; ++i)
            {
                _axis_dist[i] = (float)Math.Log10(Math.Max(freeview.znear, __axis_dist[i]));
                axis_dist[i] = (float)Math.Pow(10.0, Math.Floor(_axis_dist[i]));
            }

            int[] floor_viewpos = new int[numdims];
            float[] floor_viewpos10 = new float[numdims], axis_dist_fract = new float[numdims];
            Matrix4[] scalematrix = new Matrix4[numdims];
            for(int d = 0; d < numdims; ++d)
            {
                floor_viewpos[d] = Math.Abs((int)(Math.Floor(freeview.viewpos[d] / axis_dist[d] * 10.0f) / 10.0f));
                floor_viewpos10[d] = Math.Abs((float)Math.Floor(freeview.viewpos[d] / axis_dist[d] / 10.0f) * axis_dist[d] * 10.0f);
                axis_dist_fract[d] = (_axis_dist[d] + 100.0f) % 1.0f; //EDIT: 100.0f ... constant to keep log positive
                scalematrix[d] = Matrix4.CreateScale(axis_dist[d]);
            }

            Vector3[] unitvector = {
                new Vector3(1.0f, 0.0f, 0.0f),
                new Vector3(0.0f, 1.0f, 0.0f),
                new Vector3(0.0f, 0.0f, 1.0f)
            };

            Matrix4[] tickrotmatrix = {
                Matrix4.CreateRotationY(MathHelper.PiOver2) * Matrix4.CreateRotationX(MathHelper.PiOver2),
                Matrix4.CreateRotationX(-MathHelper.PiOver2) * Matrix4.CreateRotationY(-MathHelper.PiOver2),
                Matrix4.Identity
            };

            // >>> Draw axes

            GL.LineWidth(4.0f);

            axismesh.Bind(Common.sdrSolidColor);

            // Draw axes in positive directions
            Common.sdrSolidColor.Bind(viewprojmatrix);
            GL.Uniform4(Common.sdrSolidColor_colorUniform, POSITIVE_AXIS_COLOR);
            axismesh.Draw(0, 2 * numdims);

            // Draw axes in negative directions
            Common.sdrSolidColor.Bind(Matrix4.CreateRotationY(MathHelper.Pi) * Matrix4.CreateRotationZ(MathHelper.PiOver2) * viewprojmatrix);
            GL.Uniform4(Common.sdrSolidColor_colorUniform, NEGATIVE_AXIS_COLOR);
            axismesh.Draw(0, 2 * numdims);

            // >>> Draw selection AABB

            if(selectionAabb != null)
            {
                linemesh.Bind(Common.sdrSolidColor);

                Matrix4 selectionAabbTransform = selectionAabb.GetTransform();
                Matrix4 offsetTransform = Matrix4.CreateTranslation(0.0f, 0.0f, -0.00001f);

                Common.sdrSolidColor.Bind(tickrotmatrix[0] * selectionAabbTransform * Matrix4.CreateScale(unitvector[0]) * viewprojmatrix * offsetTransform);
                GL.Uniform4(Common.sdrSolidColor_colorUniform, selectionAabbColor);
                linemesh.Draw();
                Common.sdrSolidColor.Bind(tickrotmatrix[1] * selectionAabbTransform * Matrix4.CreateScale(unitvector[1]) * viewprojmatrix * offsetTransform);
                linemesh.Draw();
                Common.sdrSolidColor.Bind(tickrotmatrix[2] * selectionAabbTransform * Matrix4.CreateScale(unitvector[2]) * viewprojmatrix * offsetTransform);
                linemesh.Draw();
            }

            // >>> Draw ticks

            GL.LineWidth(2.0f);

            tickmesh.Bind(Common.sdrSolidColor);

            for(int d = 0; d < numdims; ++d)
            {
                if(__axis_dist[d] < freeview.znear)
                    continue;

                for(int t = floor_viewpos[d] + LABEL_CAM_DISTANCE; t >= floor_viewpos[d]; --t)
                {
                    if(t == 0)
                        continue;

                    Vector3 lblpos = unitvector[d] * (float)t * axis_dist[d];
                    float lbldist = (freeview.viewpos - lblpos).Length;

                    float opacity = (float)Math.Pow(axis_dist_fract[d], LABEL_AXIS_DISTANCE_FADE);
//.........这里部分代码省略.........
开发者ID:RcSepp,项目名称:global_view,代码行数:101,代码来源:LineGrid.cs


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