Ejemplo n.º 1
0
 public override void Draw(IBaseRender render)
 {
     if (Entity != null && Mesh != null)
     {
         if (texture != null)
         {
             render.Draw(mesh, Entity.Transformation.GlobalMatrix, renderMode, texture);
         }
         else
         {
             render.Draw(mesh, Entity.Transformation.GlobalMatrix, renderMode);
         }
     }
 }
Ejemplo n.º 2
0
        public override void DrawHelper(IBaseRender render)
        {
            if (RenderInEditor)
            {
                Mesh cube = (Mesh)Resource.FindResource(typeof(Mesh), "Cube");

                Matrix4 mat = Entity.Transformation.GlobalMatrix;

                mat = Matrix4.Scale(size) * mat;

                render.Draw(cube, mat, RenderMode.Lines, new OpenTK.Graphics.Color4(0.0f, 1.0f, 0.0f, 1.0f));
            }
        }
Ejemplo n.º 3
0
        public void DrawHelper(IBaseRender render)
        {
            if (mesh == null)
            {
                mesh = (Mesh)Resource.FindResource(typeof(Mesh), "Light");
            }

            if (Entity != null && mesh != null)
            {
                Matrix4 mat   = Entity.Transformation.GlobalMatrix;
                Vector3 scale = Entity.Transformation.GlobalScale;
                mat = Matrix4.Scale(1.0f / scale.X, 1.0f / scale.Y, 1.0f / scale.Z) * mat;
                render.Draw(mesh, mat, RenderMode.Normal, new Color4(1.0f, 1.0f, 0.0f, 0.0f));
            }
        }
Ejemplo n.º 4
0
        private void RenderHelpers(bool selection)
        {
            if (selection == false)
            {
                render.ResetAllLights();
            }

            //Dibujo la grilla
            if (selection == false && drawGrid)
            {
                render.Draw(meshGrid, Matrix4.Identity, RenderMode.Lines);
            }

            //Dibujo los objetos de edición
            if (scene.EditMode)
            {
                foreach (LightSource light in Component.AllComponentsOfType(typeof(LightSource)))
                {
                    if (selection)
                    {
                        GL.LoadName(light.Id);
                    }
                    light.DrawHelper(render);
                }
            }

            if (selectedEntity != null)
            {
                //Dibujo las flechas
                Matrix4 mat         = selectedEntity.Transformation.GlobalMatrix;
                Vector3 scaleObject = selectedEntity.Transformation.GlobalScale;

                float helperSize = 1.0f;

                mat = Matrix4.Scale(helperSize / scaleObject.X, helperSize / scaleObject.Y, helperSize / scaleObject.Z) * mat;

                render.ClearZBuffer();

                mat = Matrix4.Translation(0, 1.0f, 0) * mat;

                if (selection)
                {
                    GL.LoadName(-2); //Y
                }
                render.Draw(meshArrow, mat, RenderMode.Normal, new Color4(0, 1, 0, 0));
                render.Draw(meshArrow, mat, RenderMode.Lines, new Color4(0, 0, 0, 0));

                mat = Matrix4.Translation(0, -1.0f, -1.0f) * mat;
                mat = Matrix4.Rotate(Quaternion.FromAxisAngle(Vector3.UnitX, Functions.DegreesToRadians(-90))) * mat;

                if (selection)
                {
                    GL.LoadName(-3); //Z
                }
                render.Draw(meshArrow, mat, RenderMode.Normal, new Color4(0, 0, 1, 0));
                render.Draw(meshArrow, mat, RenderMode.Lines, new Color4(0, 0, 0, 0));

                mat = Matrix4.Translation(1.0f, -1.0f, 0.0f) * mat;
                mat = Matrix4.Rotate(Quaternion.FromAxisAngle(Vector3.UnitZ, Functions.DegreesToRadians(-90))) * mat;

                if (selection)
                {
                    GL.LoadName(-1); //X
                }
                render.Draw(meshArrow, mat, RenderMode.Normal, new Color4(1, 0, 0, 0));
                render.Draw(meshArrow, mat, RenderMode.Lines, new Color4(0, 0, 0, 0));

                if (selection == false)
                {
                    //Dibujo los elementos colisionables que contenga el objeto seleccionado
                    foreach (Collisionable col in selectedEntity.FindChildComponents(typeof(Collisionable)))
                    {
                        col.DrawHelper(render);
                    }
                }
            }
        }