public OctreeNode crearOctree(List <TgcMesh> modelos, TgcBoundingAxisAlignBox sceneBounds) { var rootNode = new OctreeNode(); var pMax = sceneBounds.PMax; var pMin = sceneBounds.PMin; //Calcular punto medio y centro var midSize = sceneBounds.calculateAxisRadius(); var 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); }
/// <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(TgcBoundingAxisAlignBox boundingBox) { CameraCenter = boundingBox.calculateBoxCenter(); var r = boundingBox.calculateBoxRadius(); CameraDistance = 2 * r; }
/// <summary> /// Hacer visible las meshes de un nodo si es visible por el Frustum /// </summary> private void testChildVisibility(TgcFrustum frustum, QuadtreeNode childNode, float boxLowerX, float boxLowerY, float boxLowerZ, float boxUpperX, float boxUpperY, float boxUpperZ) { //test frustum-box intersection var caja = new TgcBoundingAxisAlignBox( new TGCVector3(boxLowerX, boxLowerY, boxLowerZ), new TGCVector3(boxUpperX, boxUpperY, boxUpperZ)); var distanceToCamera = caja.calculateBoxCenter() - Camera.Position; if (TGCVector3.Length(distanceToCamera) > 10000 + caja.calculateBoxRadius()) { return; } var c = TgcCollisionUtils.classifyFrustumAABB(frustum, caja); //complementamente adentro: cargar todos los hijos directamente, sin testeos if (c == TgcCollisionUtils.FrustumResult.INSIDE) { addAllLeafMeshes(childNode); } //parte adentro: seguir haciendo testeos con hijos else if (c == TgcCollisionUtils.FrustumResult.INTERSECT) { findVisibleMeshes(frustum, childNode, boxLowerX, boxLowerY, boxLowerZ, boxUpperX, boxUpperY, boxUpperZ); } }
public static Parallelepiped fromBounding(TgcBoundingAxisAlignBox b) { var box = new Parallelepiped(); var size = b.calculateSize(); var pos = b.calculateBoxCenter(); box.setVertex(size, pos); return(box); }
public QuadTreeNode crearQuadTree(List <StaticObject> StaticObjects, TgcBoundingAxisAlignBox sceneBounds) { var rootNode = new QuadTreeNode(); //Calcular punto medio y centro var midSize = sceneBounds.calculateAxisRadius(); var center = sceneBounds.calculateBoxCenter(); //iniciar generacion recursiva de octree doSectorQuadTreeX(rootNode, center, midSize, 0, StaticObjects); return(rootNode); }
public QuadtreeNode crearQuadtree(List <TgcMesh> TgcMeshs, TgcBoundingAxisAlignBox sceneBounds) { var rootNode = new QuadtreeNode(); //Calcular punto medio y centro var midSize = sceneBounds.calculateAxisRadius(); var 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); }
/// <summary> /// Distancia entre un objeto y la camara /// </summary> public static float distanceFromCameraToObject(MeshCreatorCamera camera, TgcBoundingAxisAlignBox aabb) { return(distanceFromCameraToPoint(camera, aabb.calculateBoxCenter())); }