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


C# TgcBoundingBox.calculateAxisRadius方法代码示例

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


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

示例1: crearOctree

        public OctreeNode crearOctree(List<TgcMesh> modelos, TgcBoundingBox sceneBounds)
        {
            OctreeNode rootNode = new OctreeNode();

            Vector3 pMax = sceneBounds.PMax;
            Vector3 pMin = sceneBounds.PMin;

            //Calcular punto medio y centro
            Vector3 midSize = sceneBounds.calculateAxisRadius();
            Vector3 center = sceneBounds.calculateBoxCenter();

            //iniciar generacion recursiva de octree
            doSectorOctreeX(rootNode, center, midSize, 0, modelos);

            //podar nodos innecesarios
            deleteEmptyNodes(rootNode.children);

            //eliminar hijos que subdividen sin necesidad
            //deleteSameMeshCountChilds(rootNode);

            //imprimir por consola el octree
            //printDebugOctree(rootNode);

            //imprimir estadisticas de debug
            //printEstadisticasOctree(rootNode);

            return rootNode;
        }
开发者ID:aniPerezG,项目名称:barbalpha,代码行数:28,代码来源:OctreeBuilder.cs

示例2: crearQuadtree

        public QuadtreeNode crearQuadtree(List<TgcMesh> TgcMeshs, TgcBoundingBox sceneBounds)
        {
            QuadtreeNode rootNode = new QuadtreeNode();

            //Calcular punto medio y centro
            Vector3 midSize = sceneBounds.calculateAxisRadius();
            Vector3 center = sceneBounds.calculateBoxCenter();

            //iniciar generacion recursiva de octree
            doSectorQuadtreeX(rootNode, center, midSize, 0, TgcMeshs);

            //podar nodos innecesarios
            optimizeSectorQuadtree(rootNode.children);

            //imprimir por consola el octree
            //printDebugQuadtree(rootNode);

            //imprimir estadisticas de debug
            //printEstadisticasQuadtree(rootNode);

            return rootNode;
        }
开发者ID:aniPerezG,项目名称:barbalpha,代码行数:22,代码来源:QuadtreeBuilder.cs

示例3: testTriangleAABB

        /// <summary>
        /// /// Indica si un Triangulo colisiona con un BoundingBox
        /// Basado en:
        /// http://fileadmin.cs.lth.se/cs/Personal/Tomas_Akenine-Moller/code/tribox3.txt
        /// </summary>
        /// <param name="vert0">Vertice 0 del triángulo</param>
        /// <param name="vert1">Vertice 1 del triángulo</param>
        /// <param name="vert2">Vertice 2 del triángulo</param>
        /// <param name="aabb">BoundingBox</param>
        /// <returns>True si hay colisión.</returns>
        public static bool testTriangleAABB(Vector3 vert0, Vector3 vert1, Vector3 vert2, TgcBoundingBox aabb)
        {
            /*   use separating axis theorem to test overlap between triangle and box need to test for overlap in these directions:
            *    1) the {x,y,z}-directions (actually, since we use the AABB of the triangle we do not even need to test these)
            *    2) normal of the triangle
            *    3) crossproduct(edge from tri, {x,y,z}-directin) this gives 3x3=9 more tests
            */

            //Compute box center and boxhalfsize (if not already given in that format)
            Vector3 boxcenter = aabb.calculateBoxCenter();
            Vector3 boxhalfsize = aabb.calculateAxisRadius();

            //Aux vars
            Vector3[] triverts = new Vector3[3] { vert0, vert1, vert2 };
            float min,max,p0,p1,p2,rad,fex,fey,fez;

            //move everything so that the boxcenter is in (0,0,0)
            Vector3 v0 = Vector3.Subtract(triverts[0], boxcenter);
            Vector3 v1 = Vector3.Subtract(triverts[1], boxcenter);
            Vector3 v2 = Vector3.Subtract(triverts[2], boxcenter);

            //compute triangle edges
            Vector3 e0 = Vector3.Subtract(v1, v0); //tri edge 0
            Vector3 e1 = Vector3.Subtract(v2, v1); //tri edge 1
            Vector3 e2 = Vector3.Subtract(v0, v2); //tri edge 2

            //Bullet 3:
            //test the 9 tests first (this was faster)

            //edge 0
            fex = FastMath.Abs(e0.X);
            fey = FastMath.Abs(e0.Y);
            fez = FastMath.Abs(e0.Z);

            //AXISTEST_X01
            p0 = e0.Z * v0.Y - e0.Y * v0.Z;
            p2 = e0.Z * v2.Y - e0.Y * v2.Z;
            if (p0 < p2) { min = p0; max = p2; } else { min = p2; max = p0; }
            rad = fez * boxhalfsize.Y + fey * boxhalfsize.Z;
            if (min > rad || max < -rad) return false;

            //AXISTEST_Y02
            p0 = -e0.Z * v0.X + e0.X * v0.Z;
            p2 = -e0.Z * v2.X + e0.X * v2.Z;
            if (p0 < p2) { min = p0; max = p2; } else { min = p2; max = p0; }
            rad = fez * boxhalfsize.X + fex * boxhalfsize.Z;
            if (min > rad || max < -rad) return false;

            //AXISTEST_Z12
            p1 = e0.Y * v1.X - e0.X * v1.Y;
            p2 = e0.Y * v2.X - e0.X * v2.Y;
            if (p2 < p1) { min = p2; max = p1; } else { min = p1; max = p2; }
            rad = fey * boxhalfsize.X + fex * boxhalfsize.Y;
            if (min > rad || max < -rad) return false;

            //edge 1
            fex = FastMath.Abs(e1.X);
            fey = FastMath.Abs(e1.Y);
            fez = FastMath.Abs(e1.Z);

            //AXISTEST_X01
            p0 = e1.Z * v0.Y - e1.Y * v0.Z;
            p2 = e1.Z * v2.Y - e1.Y * v2.Z;
            if (p0 < p2) { min = p0; max = p2; } else { min = p2; max = p0; }
            rad = fez * boxhalfsize.Y + fey * boxhalfsize.Z;
            if (min > rad || max < -rad) return false;

            //AXISTEST_Y02
            p0 = -e1.Z * v0.X + e1.X * v0.Z;
            p2 = -e1.Z * v2.X + e1.X * v2.Z;
            if (p0 < p2) { min = p0; max = p2; } else { min = p2; max = p0; }
            rad = fez * boxhalfsize.X + fex * boxhalfsize.Z;
            if (min > rad || max < -rad) return false;

            //AXISTEST_Z0
            p0 = e1.Y * v0.X - e1.X * v0.Y;
            p1 = e1.Y * v1.X - e1.X * v1.Y;
            if (p0 < p1) { min = p0; max = p1; } else { min = p1; max = p0; }
            rad = fey * boxhalfsize.X + fex * boxhalfsize.Y;
            if (min > rad || max < -rad) return false;

            //edge 2
            fex = FastMath.Abs(e2.X);
            fey = FastMath.Abs(e2.Y);
            fez = FastMath.Abs(e2.Z);

            //AXISTEST_X2
            p0 = e2.Z * v0.Y - e2.Y * v0.Z;
            p1 = e2.Z * v1.Y - e2.Y * v1.Z;
            if (p0 < p1) { min = p0; max = p1; } else { min = p1; max = p0; }
//.........这里部分代码省略.........
开发者ID:faloi,项目名称:tegece,代码行数:101,代码来源:TgcCollisionUtils.cs


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