Ejemplo n.º 1
0
        public void Init()
        {
            noteShader = MakeShader(noteShaderVert, noteShaderFrag);
            //collision = new CollisionSystemSAP();
            collision     = new CollisionSystemPersistentSAP();
            world         = new World(collision);
            world.Gravity = new JVector(0, -30, 0);
            util          = new Util();

            uNoteMVP     = GL.GetUniformLocation(noteShader, "MVP");
            uNoteShading = GL.GetUniformLocation(noteShader, "shading");

            noteVert  = GL.GenBuffer();
            noteCol   = GL.GenBuffer();
            noteIndx  = GL.GenBuffer();
            noteShade = GL.GenBuffer();

            noteVertBuff  = new double[noteBuffLen * 8 * 3];
            noteColBuff   = new float[noteBuffLen * 8 * 4];
            noteShadeBuff = new float[noteBuffLen * 8];

            noteIndxBuff = new int[noteBuffLen * 12 * 3];

            for (int i = 0; i < noteBuffLen; i++)
            {
                var j = i * 3 * 12;
                var p = i * 8;
                noteIndxBuff[j++] = p + 0;
                noteIndxBuff[j++] = p + 1;
                noteIndxBuff[j++] = p + 3;
                noteIndxBuff[j++] = p + 0;
                noteIndxBuff[j++] = p + 3;
                noteIndxBuff[j++] = p + 2;

                noteIndxBuff[j++] = p + 0;
                noteIndxBuff[j++] = p + 5;
                noteIndxBuff[j++] = p + 1;
                noteIndxBuff[j++] = p + 0;
                noteIndxBuff[j++] = p + 4;
                noteIndxBuff[j++] = p + 5;

                noteIndxBuff[j++] = p + 1;
                noteIndxBuff[j++] = p + 5;
                noteIndxBuff[j++] = p + 7;
                noteIndxBuff[j++] = p + 1;
                noteIndxBuff[j++] = p + 7;
                noteIndxBuff[j++] = p + 3;

                noteIndxBuff[j++] = p + 3;
                noteIndxBuff[j++] = p + 6;
                noteIndxBuff[j++] = p + 7;
                noteIndxBuff[j++] = p + 2;
                noteIndxBuff[j++] = p + 6;
                noteIndxBuff[j++] = p + 3;

                noteIndxBuff[j++] = p + 0;
                noteIndxBuff[j++] = p + 2;
                noteIndxBuff[j++] = p + 4;
                noteIndxBuff[j++] = p + 2;
                noteIndxBuff[j++] = p + 6;
                noteIndxBuff[j++] = p + 4;

                noteIndxBuff[j++] = p + 4;
                noteIndxBuff[j++] = p + 6;
                noteIndxBuff[j++] = p + 7;
                noteIndxBuff[j++] = p + 4;
                noteIndxBuff[j++] = p + 7;
                noteIndxBuff[j++] = p + 5;
            }
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, noteIndx);
            GL.BufferData(
                BufferTarget.ElementArrayBuffer,
                (IntPtr)(noteIndxBuff.Length * 4),
                noteIndxBuff,
                BufferUsageHint.StaticDraw);

            GLUtils.GenFrameBufferTexture3d(renderSettings.width, renderSettings.height, out buffer3dbuf, out buffer3dtex, out buffer3dbufdepth);
            Console.WriteLine("Initialised PianoFallRender");
            Initialized = true;
        }