Пример #1
0
        /// <summary>
        /// Hacer visible las meshes de un nodo si es visible por el Frustum
        /// </summary>
        private void testChildVisibility(TgcFrustum frustum, OctreeNode childNode,
                                         float boxLowerX, float boxLowerY, float boxLowerZ, float boxUpperX, float boxUpperY, float boxUpperZ)
        {
            if (childNode == null)
            {
                return;
            }

            //test frustum-box intersection
            TgcBoundingBox caja = new TgcBoundingBox(
                new Vector3(boxLowerX, boxLowerY, boxLowerZ),
                new Vector3(boxUpperX, boxUpperY, boxUpperZ));

            TgcCollisionUtils.FrustumResult 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);
            }
        }
Пример #2
0
 /// <summary>
 /// Calcula el BoundingBox de la malla, en base a todos sus vertices.
 /// Llamar a este metodo cuando ha cambiado la estructura interna de la malla.
 /// </summary>
 public TgcBoundingBox createBoundingBox()
 {
     //Obtener vertices en base al tipo de malla
     Vector3[] points = getVertexPositions();
     this.boundingBox = TgcBoundingBox.computeFromPoints(points);
     return(this.boundingBox);
 }
Пример #3
0
        private void ColisionNave(float elapsedTime)
        {
            TgcBoundingBox NaveBBox    = nave.Modelo.BoundingBox;
            TgcBoundingBox EnemigoBBox = NaveEnemiga1.Modelo.BoundingBox;

            if (TgcCollisionUtils.classifyBoxBox(NaveBBox, EnemigoBBox) != TgcCollisionUtils.BoxBoxResult.Afuera) // CONVERTIR EN UN FOREACH CUANDO HAYA LISTA DE ENEMIGOS
            {
                NaveEnemiga1.Modelo.Position -= new Vector3(-50, 0, 0);
                return;
            }

            foreach (TgcMesh mesh in Universo.Meshes)
            {
                if (mesh.Name == "Universo")
                {
                    continue;
                }

                TgcBoundingBox SceneBBox = mesh.BoundingBox;
                TgcCollisionUtils.BoxBoxResult collisionResult = TgcCollisionUtils.classifyBoxBox(NaveBBox, SceneBBox);

                if (collisionResult != TgcCollisionUtils.BoxBoxResult.Afuera)
                {
                    nave.Modelo.moveOrientedY(10000f * elapsedTime);
                    return;
                }
            }
        }
Пример #4
0
        /// <summary>
        ///     Prepara una nueva animacion para ser ejecutada
        /// </summary>
        private void initAnimationSettings(string animationName, bool playLoop, float userFrameRate)
        {
            IsAnimating      = true;
            CurrentAnimation = Animations[animationName];
            PlayLoop         = playLoop;
            currentTime      = 0;
            CurrentFrame     = 0;

            //Cambiar BoundingBox
            boundingBox = CurrentAnimation.BoundingBox;
            updateBoundingBox();

            //Si el usuario no especifico un FrameRate, tomar el default de la animacion
            if (userFrameRate == -1f)
            {
                FrameRate = CurrentAnimation.Data.frameRate;
            }
            else
            {
                FrameRate = userFrameRate;
            }

            //La duracion de la animacion.
            animationTimeLenght = CurrentAnimation.Data.framesCount / FrameRate;
        }
Пример #5
0
        public Grid(MeshCreatorControl control)
        {
            this.control = control;

            //El bounding box del piso es bien grande para hacer colisiones
            boundingBox = new TgcBoundingBox(new Vector3(-BIG_VAL, -SMALL_VAL, -BIG_VAL), new Vector3(BIG_VAL, 0, BIG_VAL));

            //Planos para colision de picking
            pickingXZAabb = new TgcBoundingBox(new Vector3(-BIG_VAL, -SMALL_VAL, -BIG_VAL), new Vector3(BIG_VAL, 0, BIG_VAL));
            pickingXYAabb = new TgcBoundingBox(new Vector3(-BIG_VAL, -BIG_VAL, -SMALL_VAL), new Vector3(BIG_VAL, BIG_VAL, 0));
            pickingYZAabb = new TgcBoundingBox(new Vector3(-SMALL_VAL, -BIG_VAL, -BIG_VAL), new Vector3(0, BIG_VAL, BIG_VAL));

            vertices = new CustomVertex.PositionColored[12 * 2 * 2];
            int color = Color.FromArgb(76, 76, 76).ToArgb();

            //10 lineas horizontales en X
            for (int i = 0; i < 11; i++)
            {
                vertices[i * 2]     = new CustomVertex.PositionColored(-GRID_RADIUS, 0, -GRID_RADIUS + LINE_SEPARATION * i, color);
                vertices[i * 2 + 1] = new CustomVertex.PositionColored(GRID_RADIUS, 0, -GRID_RADIUS + LINE_SEPARATION * i, color);
            }

            //10 lineas horizontales en Z
            for (int i = 11; i < 22; i++)
            {
                vertices[i * 2]     = new CustomVertex.PositionColored(-GRID_RADIUS * 3 + LINE_SEPARATION * i - LINE_SEPARATION, 0, -GRID_RADIUS, color);
                vertices[i * 2 + 1] = new CustomVertex.PositionColored(-GRID_RADIUS * 3 + LINE_SEPARATION * i - LINE_SEPARATION, 0, GRID_RADIUS, color);
            }
        }
Пример #6
0
        public void LoadFromByteArray(byte[] buffer, int offset)
        {
            cluster = BitConverter.ToInt32(buffer, offset);
            area    = BitConverter.ToInt32(buffer, offset + 4);

            // en el archivo BSP Usan la Z como si fuera el Eje vertical,
            //aca hay que invertir el Z por el Y
            mins[0] = BitConverter.ToInt32(buffer, offset + 8);
            mins[1] = BitConverter.ToInt32(buffer, offset + 16);
            mins[2] = BitConverter.ToInt32(buffer, offset + 12);

            maxs[0] = BitConverter.ToInt32(buffer, offset + 20);
            maxs[1] = BitConverter.ToInt32(buffer, offset + 28);
            maxs[2] = BitConverter.ToInt32(buffer, offset + 24);

            Vector3 pMin = new Vector3(Math.Min(mins[0], maxs[0]), Math.Min(mins[1], maxs[1]), Math.Min(mins[2], maxs[2]));
            Vector3 pMax = new Vector3(Math.Max(mins[0], maxs[0]), Math.Max(mins[1], maxs[1]), Math.Max(mins[2], maxs[2]));

            boundingBox = new TgcBoundingBox(pMin, pMax);

            firstLeafSurface = BitConverter.ToInt32(buffer, offset + 32);
            numLeafSurfaces  = BitConverter.ToInt32(buffer, offset + 36);

            firstLeafBrush = BitConverter.ToInt32(buffer, offset + 40);
            numLeafBrushes = BitConverter.ToInt32(buffer, offset + 44);
        }
Пример #7
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(-10, 0, -10), new Vector3(10, 20, 10));
            gestureAnalizer.setSceneBounds(sceneBounds);

            //Crear mueble de fondo
            mueble          = TgcBox.fromSize(new Vector3(20, 20, 5), Color.SandyBrown);
            mueble.Position = new Vector3(0, 10, -10);

            //Crear algunos cajones
            Vector3 muebleCenterPos = mueble.Position;

            cajones = new List <GestureLocker>();
            cajones.Add(crearCajon(muebleCenterPos + new Vector3(-3, 0, 0.25f), new Vector3(5, 2, 5)));
            cajones.Add(crearCajon(muebleCenterPos + new Vector3(0, 3, 0.25f), new Vector3(5, 2, 5)));
            cajones.Add(crearCajon(muebleCenterPos + new Vector3(3, 0, 0.25f), new Vector3(5, 2, 5)));


            GuiController.Instance.FpsCamera.Enable = true;
            GuiController.Instance.FpsCamera.setCamera(new Vector3(-3.5508f, 16.5873f, 13.2958f), new Vector3(-3.535f, 16.3069f, 12.336f));

            center = TgcBox.fromSize(new Vector3(0, 0, 0), new Vector3(1, 1, 1), Color.Blue);
        }
Пример #8
0
        public override void init()
        {
            Microsoft.DirectX.Direct3D.Device d3dDevice = GuiController.Instance.D3dDevice;

            //Cuerpo principal que se controla con el teclado
            box = TgcBox.fromSize(new Vector3(0, 10, 0), new Vector3(10, 10, 10), Color.Blue);

            //triangulo
            triangle    = new CustomVertex.PositionColored[3];
            triangle[0] = new CustomVertex.PositionColored(-100, 0, 0, Color.Red.ToArgb());
            triangle[1] = new CustomVertex.PositionColored(0, 0, 50, Color.Green.ToArgb());
            triangle[2] = new CustomVertex.PositionColored(0, 100, 0, Color.Blue.ToArgb());
            triagleAABB = TgcBoundingBox.computeFromPoints(new Vector3[] { triangle[0].Position, triangle[1].Position, triangle[2].Position });

            //box2
            box2 = TgcBox.fromSize(new Vector3(-50, 10, -20), new Vector3(15, 15, 15), Color.Violet);

            //sphere
            sphere = new TgcBoundingSphere(new Vector3(30, 20, -20), 15);

            //OBB: computar OBB a partir del AABB del mesh.
            TgcSceneLoader loader  = new TgcSceneLoader();
            TgcMesh        meshObb = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Vehiculos\\StarWars-ATST\\StarWars-ATST-TgcScene.xml").Meshes[0];

            obb = TgcObb.computeFromAABB(meshObb.BoundingBox);
            meshObb.dispose();
            obb.move(new Vector3(100, 0, 30));
            obb.setRotation(new Vector3(0, FastMath.PI / 4, 0));


            //Configurar camara en Tercer Persona
            GuiController.Instance.ThirdPersonCamera.Enable = true;
            GuiController.Instance.ThirdPersonCamera.setCamera(box.Position, 30, -75);
        }
Пример #9
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;
        }
Пример #10
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));
        }
Пример #11
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);
        }
        public HollowObbCollider(TgcBoundingBox bb, Vector3 translation, Vector3 minCornerScale, Vector3 maxCornerScale)
        {
            var obb = TgcObb.computeFromAABB(bb);

            _HollowObbCollider(obb, translation, minCornerScale, maxCornerScale);
            obb.dispose();
        }
Пример #13
0
        /// <summary>
        /// Velocidad de incremento XY con el mouse, segun la distancia
        /// del objeto a la camara
        /// </summary>
        public static Vector2 getMouseIncrementXYSpeed(MeshCreatorCamera camera, TgcBoundingBox aabb, Vector2 mouseMove)
        {
            float dist = distanceFromCameraToObject(camera, aabb);

            mouseMove.Multiply(dist / 500);
            return(mouseMove);
        }
Пример #14
0
        public override void render(float elapsedTime)
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Si hacen clic con el mouse, ver si hay colision RayAABB
            if (GuiController.Instance.D3dInput.buttonPressed(TgcViewer.Utils.Input.TgcD3dInput.MouseButtons.BUTTON_LEFT))
            {
                //Actualizar Ray de colisión en base a posición del mouse
                pickingRay.updateRay();


                //Testear Ray contra el AABB de todos los meshes
                foreach (TgcBox box in boxes)
                {
                    TgcBoundingBox aabb = box.BoundingBox;

                    //Ejecutar test, si devuelve true se carga el punto de colision collisionPoint
                    selected = TgcCollisionUtils.intersectRayAABB(pickingRay.Ray, aabb, out collisionPoint);
                    if (selected)
                    {
                        selectedMesh = box;
                        break;
                    }
                }
            }



            //Renderizar modelos
            foreach (TgcBox box in boxes)
            {
                box.render();
            }



            //Renderizar BoundingBox del mesh seleccionado
            if (selected)
            {
                //Render de AABB
                selectedMesh.BoundingBox.render();

                //Cargar punto de colision
                GuiController.Instance.UserVars.setValue("CollP-X:", collisionPoint.X);
                GuiController.Instance.UserVars.setValue("CollP-Y:", collisionPoint.Y);
                GuiController.Instance.UserVars.setValue("CollP-Z:", collisionPoint.Z);

                //Dibujar caja que representa el punto de colision
                collisionPointMesh.Position = collisionPoint;
                collisionPointMesh.render();
            }
            else
            {
                //Reset de valores
                GuiController.Instance.UserVars.setValue("CollP-X:", 0);
                GuiController.Instance.UserVars.setValue("CollP-Y:", 0);
                GuiController.Instance.UserVars.setValue("CollP-Z:", 0);
            }
        }
Пример #15
0
        /// <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);
        }
Пример #16
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();
            }
        }
Пример #17
0
 public TgcSkeletalAnimation(string name, int frameRate, int framesCount,
                             List <TgcSkeletalAnimationFrame>[] boneFrames, TgcBoundingBox boundingBox)
 {
     Name        = name;
     FrameRate   = frameRate;
     FramesCount = framesCount;
     BoneFrames  = boneFrames;
     BoundingBox = boundingBox;
 }
Пример #18
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);
            }
        }
Пример #19
0
        public Police(int numberOfInstances, List <TgcBoundingBox> listObjColisionables, TgcBoundingBox scene)
        {
            TgcSkeletalLoader loader    = new TgcSkeletalLoader();
            string            pathMesh  = GuiController.Instance.ExamplesMediaDir + "SkeletalAnimations\\BasicHuman\\" + "CS_Gign-TgcSkeletalMesh.xml";
            string            mediaPath = GuiController.Instance.ExamplesMediaDir + "SkeletalAnimations\\BasicHuman\\";

            original = loader.loadMeshFromFile(pathMesh, mediaPath);
            loader.loadAnimationFromFile(original, GuiController.Instance.AlumnoEjemplosMediaDir + "Kamikaze3D\\Animations\\Disparar-TgcSkeletalAnim.xml");
            loader.loadAnimationFromFile(original, GuiController.Instance.AlumnoEjemplosMediaDir + "Kamikaze3D\\Animations\\Muerte-TgcSkeletalAnim.xml");
            original.Scale = new Vector3(0.7f, 0.7f, 0.7f);
            addWeapon();

            //Crear la cantidad de instancias de este modelo, pero sin volver a cargar el modelo entero cada vez
            float offset         = 200;
            int   cantInstancias = numberOfInstances;

            instances = new List <TgcSkeletalMesh>();
            for (int i = 0; i < cantInstancias; i++)
            {
                TgcSkeletalMesh instance = original.createMeshInstance(original.Name + i);
                instance.move((i % 20) * offset, 3.5f, (i / 20) * offset);
                instance.Scale = original.Scale;

                if (TgcCollisionUtils.classifyBoxBox(instance.BoundingBox, scene) != TgcCollisionUtils.BoxBoxResult.Encerrando)
                {
                    continue; //si esta afuera del escenario lo descarto
                }
                bool colisionando = false;
                foreach (TgcBoundingBox bb in listObjColisionables)
                {
                    if (TgcCollisionUtils.classifyBoxBox(instance.BoundingBox, bb) != TgcCollisionUtils.BoxBoxResult.Afuera)
                    {
                        colisionando = true;
                        break;
                    }
                }
                if (colisionando)
                {
                    continue;              //Si colisiona con algo no se debe agregar
                }
                instances.Add(instance);
            }

            //Especificar la animación actual para todos los modelos
            original.playAnimation("Disparar");
            foreach (TgcSkeletalMesh instance in instances)
            {
                TgcBoundingBox bb = instance.BoundingBox;
                instance.playAnimation("Disparar");
                instance.BoundingBox = bb;
            }
            //foreach (TgcSkeletalMesh instance in instances)
            //{
            //    instance.playAnimation("Disparar");
            //}
        }
Пример #20
0
        /// <summary>
        /// Prepara una nueva animacion para ser ejecutada
        /// </summary>
        protected void initAnimationSettings(string animationName, bool playLoop, float userFrameRate)
        {
            isAnimating      = true;
            currentAnimation = animations[animationName];
            this.playLoop    = playLoop;
            currentTime      = 0;
            currentFrame     = 0;

            //Cambiar BoundingBox
            boundingBox = currentAnimation.BoundingBox;
            updateBoundingBox();

            //Si el usuario no especifico un FrameRate, tomar el default de la animacion
            if (userFrameRate == -1f)
            {
                frameRate = (float)currentAnimation.FrameRate;
            }
            else
            {
                frameRate = userFrameRate;
            }

            //La duracion de la animacion.
            animationTimeLenght = ((float)currentAnimation.FramesCount - 1) / frameRate;


            //Configurar postura inicial de los huesos
            for (int i = 0; i < bones.Length; i++)
            {
                TgcSkeletalBone bone = bones[i];

                if (!currentAnimation.hasFrames(i))
                {
                    throw new Exception("El hueso " + bone.Name + " no posee KeyFrames");
                }

                //Determinar matriz local inicial
                TgcSkeletalAnimationFrame firstFrame = currentAnimation.BoneFrames[i][0];
                bone.MatLocal = Matrix.RotationQuaternion(firstFrame.Rotation) * Matrix.Translation(firstFrame.Position);

                //Multiplicar por matriz del padre, si tiene
                if (bone.ParentBone != null)
                {
                    bone.MatFinal = bone.MatLocal * bone.ParentBone.MatFinal;
                }
                else
                {
                    bone.MatFinal = bone.MatLocal;
                }
            }


            //Ajustar vertices a posicion inicial del esqueleto
            updateMeshVertices();
        }
Пример #21
0
        /// <summary>
        /// Desactiva la animacion actual
        /// </summary>
        public void stopAnimation()
        {
            isAnimating = false;
            boundingBox = staticMeshBoundingBox;

            //Invocar evento de finalización
            if (AnimationEnds != null)
            {
                AnimationEnds.Invoke(this);
            }
        }
Пример #22
0
        public void init()
        {
            currentState     = State.Closed;
            waintElapsedTime = 0;
            currentMovement  = 0;
            originalPos      = conjunto.container.Position;

            TgcBoundingBox aabb = conjunto.container.createBoundingBox();

            conjuntoCenter = aabb.calculateBoxCenter();
        }
Пример #23
0
        public SmartTerrain()
        {
            enabled          = true;
            alphaBlendEnable = false;

            //Shader
            Effect    = TgcShaders.loadEffect(GuiController.Instance.ExamplesDir + "TerrainEditor\\Shaders\\EditableTerrain.fx");
            Technique = "PositionColoredTextured";

            aabb = new TgcBoundingBox();
        }
Пример #24
0
        public gui_navigate(DXGui gui, List <TgcMesh> p_meshes, int x, int y, int dx = 0, int dy = 0, int id = -1) :
            base(gui, "", x, y, dx, dy, id)
        {
            seleccionable = false;
            scrolleable   = false;
            modo_pan      = false;
            // Calculo el bounding box de la escena
            float x0 = 10000;
            float z0 = 10000;
            float x1 = -10000;
            float z1 = -10000;

            if (p_meshes != null)
            {
                foreach (TgcMesh m in p_meshes)
                {
                    TgcBoundingBox box = m.BoundingBox;
                    if (box.PMin.X < x0)
                    {
                        x0 = box.PMin.X;
                    }
                    if (box.PMin.Z < z0)
                    {
                        z0 = box.PMin.Z;
                    }
                    if (box.PMax.X > x1)
                    {
                        x1 = box.PMax.X;
                    }
                    if (box.PMax.Z > z1)
                    {
                        z1 = box.PMax.Z;
                    }
                }
            }

            min_x = x0;
            min_z = z0;
            wdx   = x1 - x0;
            wdz   = z1 - z0;

            // Calculo la escala de toda la cocina
            ex = (float)rc.Width / wdx;
            ey = (float)rc.Height / wdz;
            if (ex < ey)
            {
                ey = ex;
            }
            else
            {
                ex = ey;
            }
        }
Пример #25
0
        public override void init()
        {
            collider              = new TgcFixedYBoundingCylinder(new Vector3(0, 0, 0), 3, 3);
            collisionableSphere   = new TgcBoundingSphere(new Vector3(-6, 0, 0), 3);
            collisionableAABB     = new TgcBoundingBox(new Vector3(4, 0, -1), new Vector3(6, 2, 1));
            collisionableCylinder = new TgcFixedYBoundingCylinder(new Vector3(0, 0, -6), 2, 2);

            GuiController.Instance.Modifiers.addVertex2f("size", new Vector2(1, 1), new Vector2(5, 10), new Vector2(2, 5));
            GuiController.Instance.Modifiers.addVertex3f("position", new Vector3(-20, -20, -20), new Vector3(20, 20, 20), new Vector3(0, 0, 0));

            collider.setRenderColor(Color.LimeGreen);
        }
Пример #26
0
        public SimpleTerrain()
        {
            enabled          = true;
            alphaBlendEnable = false;

            //BoundingBox
            boundingBox = new TgcBoundingBox();

            //Shader
            this.effect    = GuiController.Instance.Shaders.VariosShader;
            this.technique = TgcShaders.T_POSITION_TEXTURED;
        }
Пример #27
0
        /// <summary>
        ///     Crear una nueva grilla
        /// </summary>
        /// <param name="modelos">Modelos a contemplar</param>
        /// <param name="sceneBounds">Límites del escenario</param>
        public void create(List <TgcMesh> modelos, TgcBoundingBox sceneBounds)
        {
            this.modelos     = modelos;
            this.sceneBounds = sceneBounds;

            //build
            grid = buildGrid(modelos, sceneBounds, new Vector3(CELL_WIDTH, CELL_HEIGHT, CELL_LENGTH));

            foreach (var mesh in modelos)
            {
                mesh.Enabled = false;
            }
        }
Пример #28
0
        /// <summary>
        /// Crear una nueva grilla
        /// </summary>
        /// <param name="modelos">Modelos a contemplar</param>
        /// <param name="sceneBounds">Límites del escenario</param>
        public void create(List <TgcMesh> modelos, TgcBoundingBox sceneBounds)
        {
            this.modelos     = modelos;
            this.sceneBounds = sceneBounds;

            //build
            grid = buildGrid(modelos, sceneBounds, new Vector3(CELL_SIZE, CELL_SIZE, CELL_SIZE));

            foreach (TgcMesh mesh in modelos)
            {
                mesh.Enabled = false;
            }
        }
Пример #29
0
        /// <summary>
        ///     Calcula el BoundingBox de la malla, en base a todos sus vertices.
        ///     Llamar a este metodo cuando ha cambiado la estructura interna de la malla.
        /// </summary>
        public TgcBoundingBox createBoundingBox()
        {
            if (boundingBox != null)
            {
                boundingBox.dispose();
                boundingBox = null;
            }
            //Obtener vertices en base al tipo de malla
            var points = getVertexPositions();

            boundingBox = TgcBoundingBox.computeFromPoints(points);
            return(boundingBox);
        }
Пример #30
0
        /// <summary>
        /// Dibujar meshes que representan los sectores del Quadtree
        /// </summary>
        public List <TgcDebugBox> createDebugQuadtreeMeshes(QuadtreeNode rootNode, TgcBoundingBox sceneBounds)
        {
            Vector3 pMax = sceneBounds.PMax;
            Vector3 pMin = sceneBounds.PMin;

            List <TgcDebugBox> debugBoxes = new List <TgcDebugBox>();

            doCreateQuadtreeDebugBox(rootNode, debugBoxes,
                                     pMin.X, pMin.Y, pMin.Z,
                                     pMax.X, pMax.Y, pMax.Z, 0);

            return(debugBoxes);
        }