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


C# TgcBoundingBox.calculateBoxCenter方法代码示例

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


在下文中一共展示了TgcBoundingBox.calculateBoxCenter方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: targetObject

  /// <summary>
  /// Configura los parámetros de la cámara en funcion del BoundingBox de un modelo
  /// </summary>
  /// <param name="boundingBox">BoundingBox en base al cual configurar</param>
 
  
  public void targetObject(TgcBoundingBox boundingBox)
  {
      cameraCenter = boundingBox.calculateBoxCenter();
      float r = boundingBox.calculateBoxRadius();
      cameraDistance = 2 * r;
  }
开发者ID:Dkazarian,项目名称:TP-TGC-Commandos-ValePorUnNombreGeek,代码行数:12,代码来源:FreeCamera.cs

示例4: 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

示例5: clonarBoundingBoxArbol

 private TgcBoundingBox clonarBoundingBoxArbol(TgcBoundingBox bb)
 {
     TgcBoundingBox bbClon = bb.clone();
     Vector3 pos = bb.calculateBoxCenter();
     pos.Y = 0f;
     pos.Z -= 40f;
     pos.X -= 30f;
     bbClon.scaleTranslate(pos, new Vector3(0.3f, 1f, 0.3f));
     return bbClon;
 }
开发者ID:julisalis,项目名称:2015-tgc-fps,代码行数:10,代码来源:EjemploAlumno.cs

示例6: testAABBCylinder

        /// <summary>
        /// Indica si un Cilindro colisiona con un AABB.
        /// Solo indica si hay colision o no. No va mas en detalle.
        /// </summary>
        /// <param name="box">AABB</param>
        /// <param name="cylinder">Cilindro alineado</param>
        /// <returns>True si hay colision</returns>
        public static bool testAABBCylinder(TgcBoundingBox box, TgcFixedYBoundingCylinder cylinder)
        {
            //datos del aabb
            Vector3 boxCenter = box.calculateBoxCenter();
            Vector3 boxHalfSize = box.calculateSize() * 0.5f;

            //datos del cilindro
            Vector3 cylCenter = cylinder.Center;
            float cylHalfLength = cylinder.HalfLength;
            float cylRadius = cylinder.Radius;

            //vector de distancias
            Vector3 distances = new Vector3(
                FastMath.Abs(boxCenter.X - cylCenter.X),
                FastMath.Abs(boxCenter.Y - cylCenter.Y),
                FastMath.Abs(boxCenter.Z - cylCenter.Z));

            //si el aabb esta muy arriba o muy abajo no hay colision
            if (distances.Y > boxHalfSize.Y + cylHalfLength) return false;

            //si el aabb esta muy lejos en x o en z no hay colision
            if (distances.X > boxHalfSize.X + cylRadius) return false;
            if (distances.Z > boxHalfSize.Z + cylRadius) return false;

            //si el centro del cilindro esta dentro del aabb hay colision
            if (distances.X <= boxHalfSize.X) return true;
            if (distances.Z <= boxHalfSize.Z) return true;

            //si el cilindro toca alguno de los extremos hay colision
            float cornerDistanceSq =
                FastMath.Pow2(distances.X - boxHalfSize.X) +
                FastMath.Pow2(distances.Z - boxHalfSize.Z);
            return (cornerDistanceSq <= FastMath.Pow2(cylRadius));
        }
开发者ID:JesusHerrera,项目名称:tgc-viewer,代码行数:41,代码来源:TgcCollisionUtils.cs

示例7: distanceFromCameraToObject

 /// <summary>
 /// Distancia entre un objeto y la camara
 /// </summary>
 public static float distanceFromCameraToObject(MeshCreatorCamera camera, TgcBoundingBox aabb)
 {
     return distanceFromCameraToPoint(camera, aabb.calculateBoxCenter());
 }
开发者ID:JesusHerrera,项目名称:tgc-viewer,代码行数:7,代码来源:MeshCreatorUtils.cs


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