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


C# TgcBoundingBox.computeCorners方法代码示例

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


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

示例1: fromBoundingBox

 /// <summary>
 /// Crear Collider a partir de BoundingBox.
 /// Crea el BoundingSphere del Collider.
 /// </summary>
 /// <param name="mesh">BoundingBox</param>
 /// <returns>Collider creado</returns>
 public static BoundingBoxCollider fromBoundingBox(TgcBoundingBox aabb)
 {
     BoundingBoxCollider collider = new BoundingBoxCollider();
     collider.aabb = aabb;
     collider.BoundingSphere = TgcBoundingSphere.computeFromPoints(aabb.computeCorners()).toClass();
     return collider;
 }
开发者ID:JesusHerrera,项目名称:tgc-viewer,代码行数:13,代码来源:BoundingBoxCollider.cs

示例2: classifyFrustumAABB

        /// <summary>
        /// Clasifica un BoundingBox respecto del Frustum
        /// </summary>
        /// <param name="frustum">Frustum</param>
        /// <param name="aabb">BoundingBox</param>
        /// <returns>Resultado de la clasificación</returns>
        public static FrustumResult classifyFrustumAABB(TgcFrustum frustum, TgcBoundingBox aabb)
        {
            int totalIn = 0;
            Plane[] frustumPlanes = frustum.FrustumPlanes;

            // get the corners of the box into the vCorner array
            Vector3[] aabbCorners = aabb.computeCorners();

            // test all 8 corners against the 6 sides
            // if all points are behind 1 specific plane, we are out
            // if we are in with all points, then we are fully in
            for(int p = 0; p < 6; ++p)
            {
                int inCount = 8;
                int ptIn = 1;

                for(int i = 0; i < 8; ++i)
                {
                    // test this point against the planes
                    if (classifyPointPlane(aabbCorners[i], frustumPlanes[p]) == PointPlaneResult.BEHIND)
                    {
                        ptIn = 0;
                        --inCount;
                    }
                }

                // were all the points outside of plane p?
                if (inCount == 0)
                {
                    return FrustumResult.OUTSIDE;
                }

                // check if they were all on the right side of the plane
                totalIn += ptIn;
            }

            // so if iTotalIn is 6, then all are inside the view
            if (totalIn == 6)
            {
                return FrustumResult.INSIDE;
            }

            // we must be partly in then otherwise
            return FrustumResult.INTERSECT;
        }
开发者ID:faloi,项目名称:tegece,代码行数:51,代码来源:TgcCollisionUtils.cs

示例3: projectAABB

        /*
        /// <summary>
        /// Proyecta un BoundingBox a un rectangulo 2D de screen space
        /// </summary>
        public static Rectangle projectAABB(TgcBoundingBox aabb)
        {
            return aabb.projectToScreen();
        }
        */
        /// <summary>
        /// Proyectar AABB a 2D
        /// </summary>
        /// <param name="box3d">BoundingBox 3D</param>
        /// <param name="box2D">Rectangulo 2D proyectado</param>
        /// <returns>False si es un caso degenerado de proyeccion y no debe considerarse</returns>
        public static bool projectBoundingBox(TgcBoundingBox box3d, out Rectangle box2D)
        {
            //Datos de viewport
            Device d3dDevice = GuiController.Instance.D3dDevice;
            Viewport viewport = d3dDevice.Viewport;
            Matrix view = d3dDevice.Transform.View;
            Matrix proj = d3dDevice.Transform.Projection;
            int width = viewport.Width;
            int height = viewport.Height;

            box2D = new Rectangle();

            //Proyectar los 8 puntos, sin dividir aun por W
            Vector3[] corners = box3d.computeCorners();
            Matrix m = view * proj;
            Vector3[] projVertices = new Vector3[corners.Length];
            for (int i = 0; i < corners.Length; i++)
            {
                Vector4 pOut = Vector3.Transform(corners[i], m);
                if (pOut.W < 0) return false;
                projVertices[i] = MeshCreatorUtils.toScreenSpace(pOut, width, height);
            }

            //Buscar los puntos extremos
            Vector2 min = new Vector2(float.MaxValue, float.MaxValue);
            Vector2 max = new Vector2(float.MinValue, float.MinValue);
            float minDepth = float.MaxValue;
            foreach (Vector3 v in projVertices)
            {
                if (v.X < min.X)
                {
                    min.X = v.X;
                }
                if (v.Y < min.Y)
                {
                    min.Y = v.Y;
                }
                if (v.X > max.X)
                {
                    max.X = v.X;
                }
                if (v.Y > max.Y)
                {
                    max.Y = v.Y;
                }

                if (v.Z < minDepth)
                {
                    minDepth = v.Z;
                }
            }

            //Clamp
            if (min.X < 0f) min.X = 0f;
            if (min.Y < 0f) min.Y = 0f;
            if (max.X >= width) max.X = width - 1;
            if (max.Y >= height) max.Y = height - 1;

            //Control de tamaño minimo
            if (max.X - min.X < 1f) return false;
            if (max.Y - min.Y < 1f) return false;

            //Cargar valores de box2D
            box2D.Location = new Point((int)min.X, (int)min.Y);
            box2D.Size = new Size((int)(max.X - min.X), (int)(max.Y - min.Y));
            return true;
        }
开发者ID:JesusHerrera,项目名称:tgc-viewer,代码行数:82,代码来源:MeshCreatorUtils.cs


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