Exemplo n.º 1
0
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Iniciar kinect
            tgcKinect = new TgcKinect();
            tgcKinect.init();
            tgcKinect.DebugSkeleton.init();

            //Analizador de gestos
            gestureAnalizer = new GestureAnalizer();
            sceneBounds     = new TgcBoundingBox(new Vector3(-50, -40, 230), new Vector3(80, 50, 290));
            gestureAnalizer.setSceneBounds(sceneBounds);
            sceneCenter = sceneBounds.calculateBoxCenter();

            sceneCenterBox = TgcBox.fromSize(sceneCenter, new Vector3(30, 30, 30), Color.Blue);

            //Crear mueble de fondo
            mueble          = TgcBox.fromSize(new Vector3(200, 100, 50), Color.SandyBrown);
            mueble.Position = new Vector3(20, 20, 200);

            //Crear puerta
            door               = new GestureDoorLeft();
            door.Mesh          = TgcBox.fromSize(new Vector3(30, 40, 4), Color.Green).toMesh("door");
            door.Mesh.Position = mueble.Position + new Vector3(-30, 20, 25);


            GuiController.Instance.FpsCamera.Enable = true;
            GuiController.Instance.FpsCamera.setCamera(new Vector3(1.5467f, 54.7247f, 401.1074f), new Vector3(1.4672f, 54.4561f, 400.1474f));
        }
Exemplo n.º 2
0
        /// <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;
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Hacer zoom a un grupo de primitivas
        /// </summary>
        public static void zoomPrimitives(MeshCreatorCamera camera, List <EditPolyPrimitive> primitives, Matrix transform)
        {
            TgcBoundingBox aabb = getSelectionBoundingBox(primitives);

            if (aabb != null)
            {
                camera.CameraCenter = Vector3.TransformCoordinate(aabb.calculateBoxCenter(), transform);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Centrar la camara sobre un objeto seleccionado
        /// </summary>
        public void zoomObject()
        {
            TgcBoundingBox aabb = MeshCreatorUtils.getSelectionBoundingBox(control.SelectionList);

            if (aabb != null)
            {
                control.Camera.CameraCenter = aabb.calculateBoxCenter();
            }
        }
Exemplo n.º 6
0
        public void init()
        {
            currentState     = State.Closed;
            waintElapsedTime = 0;
            currentMovement  = 0;
            originalPos      = conjunto.container.Position;

            TgcBoundingBox aabb = conjunto.container.createBoundingBox();

            conjuntoCenter = aabb.calculateBoxCenter();
        }
Exemplo n.º 7
0
        public override void setEnabled(bool enabled)
        {
            //Activar
            if (enabled)
            {
                Control.CurrentState = MeshCreatorControl.State.GizmoActivated;
                currentState         = State.Init;

                //Posicionar gizmo
                TgcBoundingBox aabb = MeshCreatorUtils.getSelectionBoundingBox(Control.SelectionList);
                gizmoMesh.setCenter(aabb.calculateBoxCenter(), Control.Camera);
            }
        }
        /// <summary>
        /// Activar
        /// </summary>
        public void setEnabled(bool enabled)
        {
            //Activar
            if (enabled)
            {
                editablePoly.CurrentState = EditablePoly.State.TranslateGizmo;
                currentState = State.Init;

                //Posicionar gizmo
                TgcBoundingBox aabb       = EditablePolyUtils.getSelectionBoundingBox(editablePoly.SelectionList);
                Vector3        aabbCenter = Vector3.TransformCoordinate(aabb.calculateBoxCenter(), editablePoly.Transform);
                gizmoMesh.setCenter(aabbCenter, editablePoly.Control.Camera);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Poner la camara en front view respecto de un conjunto de primitivas
        /// </summary>
        public static void setCameraFrontView(MeshCreatorCamera camera, List <EditPolyPrimitive> primitives, Matrix transform)
        {
            TgcBoundingBox aabb = getSelectionBoundingBox(primitives);
            Vector3        lookAt;

            if (aabb != null)
            {
                lookAt = Vector3.TransformCoordinate(aabb.calculateBoxCenter(), transform);
            }
            else
            {
                lookAt = new Vector3(0, 0, 0);
            }
            camera.setFixedView(lookAt, 0, 0, camera.CameraDistance);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Poner la camara en front view respecto de un objeto seleccionado
        /// </summary>
        public void setFrontView()
        {
            TgcBoundingBox aabb = MeshCreatorUtils.getSelectionBoundingBox(control.SelectionList);
            Vector3        lookAt;

            if (aabb != null)
            {
                lookAt = aabb.calculateBoxCenter();
            }
            else
            {
                lookAt = new Vector3(0, 0, 0);
            }
            control.Camera.setFixedView(lookAt, 0, 0, control.Camera.CameraDistance);
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Loader de kinect
            tgcKinect = new TgcKinect();
            tgcKinect.init();
            tgcKinect.DebugSkeleton.init();


            //Loader de focus
            FocusParser.TEXTURE_FOLDER = GuiController.Instance.ExamplesMediaDir + "Focus\\texturas\\";
            FocusParser.MESH_FOLDER    = GuiController.Instance.ExamplesMediaDir + "Focus\\texturas\\";
            FocusParser loader    = new FocusParser();
            string      fileScene = GuiController.Instance.ExamplesMediaDir + "Focus\\escena1.dat";

            loader.FromFile(fileScene);
            _meshes    = loader.Escene;
            _conjuntos = loader._focusSets;

            // Bounding box de la escena
            // Calculo el bounding box de la escena
            float x0 = 10000;
            float y0 = 10000;
            float z0 = 10000;
            float x1 = -10000;
            float y1 = -10000;
            float z1 = -10000;

            foreach (TgcMesh m in _meshes)
            {
                TgcBoundingBox box = m.BoundingBox;
                if (box.PMin.X < x0)
                {
                    x0 = box.PMin.X;
                }
                if (box.PMin.Y < y0)
                {
                    y0 = box.PMin.Y;
                }
                if (box.PMin.Z < z0)
                {
                    z0 = box.PMin.Z;
                }

                if (box.PMax.X > x1)
                {
                    x1 = box.PMax.X;
                }
                if (box.PMax.Y > y1)
                {
                    y1 = box.PMax.Y;
                }
                if (box.PMax.Z > z1)
                {
                    z1 = box.PMax.Z;
                }
            }

            bounds = new TgcBoundingBox(new Vector3(x0, y0, z0), new Vector3(x1, y1, z1));
            Vector3 c = bounds.calculateBoxCenter();

            c.Y    = 0;
            center = TgcBox.fromSize(c, new Vector3(100, 100, 100), Color.Blue);


            //Escalas y centro de la escena para kinect
            tgcKinect.PositionScale   = 1000;
            tgcKinect.sceneCenter     = c;
            tgcKinect.skeletonOffsetY = 0.75f;


            //Analizador de gestos
            gestureAnalizer = new GestureAnalizer();
            gestureAnalizer.setSceneBounds(bounds);



            //Camara
            GuiController.Instance.FpsCamera.Enable         = true;
            GuiController.Instance.FpsCamera.MovementSpeed *= 10;
            GuiController.Instance.FpsCamera.JumpSpeed     *= 10;
            GuiController.Instance.FpsCamera.setCamera(new Vector3(2000f, 1600f, -4000f), new Vector3(2000f, 500f, 0));
            //GuiController.Instance.FpsCamera.setCamera(c, c + new Vector3(0, 0, 1));



            //Separar cajones del resto del FocusSet
            cajones = new List <CajonFocus>();
            foreach (FocusSet conjunto in _conjuntos)
            {
                if (conjunto.Tipo == FocusSet.TRASLACION)
                {
                    CajonFocus cajon = new CajonFocus();
                    cajon.Conjunto = conjunto;
                    cajon.init();
                    cajones.Add(cajon);
                }
            }
        }
Exemplo n.º 13
0
 /// <summary>
 /// Distancia entre un objeto y la camara
 /// </summary>
 public static float distanceFromCameraToObject(MeshCreatorCamera camera, TgcBoundingBox aabb)
 {
     return(distanceFromCameraToPoint(camera, aabb.calculateBoxCenter()));
 }
Exemplo n.º 14
0
 public void setSceneBounds(TgcBoundingBox sceneBounds)
 {
     this.sceneBounds  = sceneBounds;
     this.sceneCenter  = sceneBounds.calculateBoxCenter();
     this.sceneExtents = sceneBounds.calculateAxisRadius();
 }
Exemplo n.º 15
0
        /// <summary>
        /// Obtener pivote central para efectuar la rotacion.
        /// Se busca el centro de todos los AABB
        /// </summary>
        public Vector3 getRotationPivot()
        {
            TgcBoundingBox aabb = MeshCreatorUtils.getSelectionBoundingBox(control.SelectionList);

            return(aabb.calculateBoxCenter());
        }