public override void ViewDidLoad()
        {
            TexturedCube tc = new TexturedCube(this);

            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            Run();
        }
Esempio n. 2
0
        public Tetromino()
        {
            GL.GenBuffers(1, out ibo_elements);
            Position = new Vector3(0, 0, 0);

            for (int i = 0; i < 4; ++i)
            {
                TexturedCube tc = new TexturedCube();
                tc.textureID = ShaderManager.Instance.textures["block"];
                Parts.Add(tc);
            }

            setPiece(Tipo.T);
        }
Esempio n. 3
0
        public static void ThreeShaders()
        {
            Cube cube1 = new Cube();
            Cube cube2 = new ColouredCube();
            Cube cube3 = new TexturedCube();
            ShaderModelRenderer sm1 = new ShaderModelRenderer(cube1);
            ShaderModelRenderer sm2 = new ShaderModelRenderer(cube2)
            {
                VertexShaderFilaneme = "Shaders/vs_col.glsl"
            };
            ShaderModelRenderer sm3 = new ShaderModelRenderer(cube3)
            {
                VertexShaderFilaneme   = "Shaders/vs_tex.glsl",
                FragmentShaderFilename = "Shaders/fs_tex.glsl"
            };

            using (WorldWindow game = new WorldWindow()
            {
                Title = "ThreeShaders"
            })
            {
                game.Camera.LookAt(new Vector3(-4, 4, -4), new Vector3());

                (cube3 as TexturedCube).TextureID = TextureLoader.LoadImage("Textures/opentksquare.png");

                game.Models.Add(sm1);
                game.Models.Add(sm2);
                game.Models.Add(sm3);

                UserInterface ui = new UserInterface(game);

                float time = 0;
                game.UpdateFrame += (o, e) =>
                {
                    time          += (float)e.Time;
                    cube1.Position = new Vector3(2, 0.05f * (float)Math.Sin(time), 0);
                    cube1.Rotation = new Vector3(0.3f * time, 0.1f * time, 0);

                    cube2.Position = new Vector3(0, 0.05f * (float)Math.Sin(time), 2);
                    cube2.Rotation = new Vector3(0.3f * time, 0.1f * time, 0);

                    cube3.Position = new Vector3(0, 0.05f * (float)Math.Sin(time), 0);
                    cube3.Rotation = new Vector3(0.3f * time, 0.1f * time, 0);

                    ui.PrintCommonStats(e.Time);
                };
                game.Run();
            }
        }
Esempio n. 4
0
        public Container(int lenght, int depth, int height)
        {
            this.length       = lenght;
            this.depth        = depth;
            this.height       = height;
            container         = new byte[height, depth];
            containerAuxiliar = new byte[height, depth];

            GL.GenBuffers(1, out ibo_elements);


            for (int i = 0; i < 10; ++i)
            {
                for (int j = 0; j < 10; ++j)
                {
                    TexturedCube v = new TexturedCube();
                    v.textureID = ShaderManager.Instance.textures["block2"];
                    v.Position  = new Vector3(i - 1, -1, j - 1);
                    Parts.Add(v);
                }
            }


            TexturedCube tc;

            for (int i = 0; i < height; ++i)
            {
                tc           = new TexturedCube();
                tc.textureID = ShaderManager.Instance.textures["block2"];
                tc.Position  = new Vector3(-1, i, -1);
                Parts.Add(tc);

                tc           = new TexturedCube();
                tc.textureID = ShaderManager.Instance.textures["block2"];
                tc.Position  = new Vector3(8, i, 8);
                Parts.Add(tc);

                tc           = new TexturedCube();
                tc.textureID = ShaderManager.Instance.textures["block2"];
                tc.Position  = new Vector3(-1, i, 8);
                Parts.Add(tc);

                tc           = new TexturedCube();
                tc.textureID = ShaderManager.Instance.textures["block2"];
                tc.Position  = new Vector3(8, i, -1);
                Parts.Add(tc);
            }
        }
Esempio n. 5
0
        static Vector3[] GenerateRandomCubes(WorldWindow game, int texID)
        {
            int    numCubes = 100;
            Random rand     = new Random();

            Vector3[] posOffsets = new Vector3[numCubes];
            for (int i = 0; i < numCubes; i++)
            {
                int  type = rand.Next(3);
                Cube cube;
                ShaderModelRenderer sm;
                if (type == 0)
                {
                    cube = new Cube();
                    sm   = new ShaderModelRenderer(cube);
                }
                else if (type == 1)
                {
                    cube = new ColouredCube();
                    sm   = new ShaderModelRenderer(cube)
                    {
                        VertexShaderFilaneme   = "Shaders/vs_col.glsl",
                        FragmentShaderFilename = "Shaders/fs.glsl"
                    };
                }
                else
                {
                    cube = new TexturedCube();
                    sm   = new ShaderModelRenderer(cube)
                    {
                        VertexShaderFilaneme   = "Shaders/vs_tex.glsl",
                        FragmentShaderFilename = "Shaders/fs_tex.glsl"
                    };
                    (cube as TexturedCube).TextureID = TextureLoader.LoadImage("Textures/opentksquare.png");
                }

                cube.Scale = new Vector3(0.5f, 0.5f, 0.5f);
                game.Models.Add(sm);
                Vector3 v = new Vector3((float)rand.NextDouble(), (float)rand.NextDouble(), (float)rand.NextDouble()) * (float)(Math.PI * 2);
                posOffsets[i] = v - (Vector3.One * (float)Math.PI);
            }
            return(posOffsets);
        }
Esempio n. 6
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            bool debug = false;

#if DEBUG
            debug = true;
#endif

            _options = new GraphicsDeviceOptions(debug, PixelFormat.R16_UNorm, false);
            GraphicsBackend backend = GraphicsDevice.IsBackendSupported(GraphicsBackend.Vulkan)
                ? GraphicsBackend.Vulkan
                : GraphicsBackend.OpenGLES;
            _view   = new VeldridSurfaceView(this, backend, _options);
            _window = new AndroidApplicationWindow(this, _view);
            _window.GraphicsDeviceCreated += (g, r, s) => _window.Run();
            _tc = new TexturedCube(_window);
            SetContentView(_view);
        }
        public void Load()
        {
            //Hololens renders in meters so 0.2f is 20cm
            _size = new CubeSize(0.2f, 0.2f, 0.2f);

            //Hold 10cm between the cubes
            _locationCube         = new Vector3(0, 0, -2.0f);
            _locationPrettyCube   = new Vector3(0.3f, 0.0f, -2.0f);
            _locationTexturedCube = new Vector3(-0.3f, 0.0f, -2.0f);

            //Color the center cube red
            _cube = new ColoredCube(_locationCube, _size, Color.Red(), _engine.GetWindow().GetDrawEngine());

            //Load the pretty cube without an initial color
            _prettyCube = new ColoredCube(_locationPrettyCube, _size, _engine.GetWindow().GetDrawEngine());

            //Load the image
            var imageData = ImageData.LoadImage("Assets\\logo.jpg");

            _texturedCube     = new TexturedCube(_locationTexturedCube, _size, _engine.GetWindow().GetDrawEngine(), imageData);
            _lightDirection   = _texturedCube.LightDirection();
            _lightDirection.Z = -1.0f;
            _lightDirection.X = -1.0f;

            //Get the rotation vector
            _rotationCube         = _cube.Rotation();
            _rotationPrettyCube   = _prettyCube.Rotation();
            _rotationTexturedCube = _texturedCube.Rotation();

            //Modify the colors of the pretty cube
            //Colors in directx go from 0 to 1 which can be translated in bytes from 0 to 255
            _prettyCube.ChangeColor(0, new Color(0, 0, 0));
            _prettyCube.ChangeColor(1, new Color(0, 0, 1));
            _prettyCube.ChangeColor(2, new Color(0, 1, 0));
            _prettyCube.ChangeColor(3, new Color(0, 1, 1));
            _prettyCube.ChangeColor(4, new Color(1, 0, 0));
            _prettyCube.ChangeColor(5, new Color(1, 0, 0));
            _prettyCube.ChangeColor(6, new Color(1, 1, 0));
            _prettyCube.ChangeColor(7, new Color(1, 1, 1));
        }
Esempio n. 8
0
        protected override void OnLoad()
        {
            // load texture from file
            using (var bitmap = new Bitmap("Data/Textures/crate.png"))
            {
                BitmapTexture.CreateCompatible(bitmap, out _texture);
                _texture.LoadBitmap(bitmap);
            }

            // initialize shaders
            _textureProgram = ProgramFactory.Create <SimpleTextureProgram>();

            // initialize cube object and base view matrix
            _objectView = _baseView = Matrix4.Identity;

            // initialize demonstration geometry
            _cube = new TexturedCube();
            _cube.UpdateBuffers();

            // set up vertex attributes for the quad
            _cubeVao = new VertexArray();
            _cubeVao.Bind();
            _cubeVao.BindAttribute(_textureProgram.InPosition, _cube.VertexBuffer);
            _cubeVao.BindAttribute(_textureProgram.InTexCoord, _cube.TexCoordBuffer);

            // Enable culling, our cube vertices are defined inside out, so we flip them
            GL.Enable(EnableCap.CullFace);
            GL.CullFace(CullFaceMode.Back);

            // initialize camera position
            Camera.DefaultState.Position = new Vector3(0, 0, 4);
            Camera.ResetToDefault();

            // set nice clear color
            GL.ClearColor(Color.MidnightBlue);

            _stopwatch.Restart();
        }
Esempio n. 9
0
        public void encajar(List <Vector3> T, Vector3 Posicion)
        {
            containerAuxiliar = new byte[height, depth];

            for (int i = 0; i < T.Count; ++i)
            {
                setIntern(containerAuxiliar, (int)(Posicion.X + T[i].X), (int)(Posicion.Y + T[i].Y), (int)(Posicion.Z + T[i].Z));
                TexturedCube tq = new TexturedCube();
                tq.Position  = new Vector3((int)(Posicion.X + T[i].X), (int)(Posicion.Y + T[i].Y), (int)(Posicion.Z + T[i].Z));
                tq.textureID = ShaderManager.Instance.textures["block"];
                Parts.Add(tq);
            }

            for (int i = 0; i < height; ++i)
            {
                for (int j = 0; j < depth; ++j)
                {
                    byte a = container[i, j];
                    byte b = containerAuxiliar[i, j];
                    container[i, j] |= b;
                }
            }
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            TexturedCube texturedCube = new TexturedCube();

            texturedCube.Run();
        }
Esempio n. 11
0
 public SampleDraw()
 {
     aCube = new TexturedCube();
 }
Esempio n. 12
0
        public MainPage()
        {
            this.InitializeComponent();

            _sample = new TexturedCube(_veldrid);
        }