Пример #1
0
        private void DrawNotes(NoteManager notes)
        {
            SongDataIO.SongData.NoteSet[] noteSet = notes.NoteSet;
            if (noteSet != null)
            {
                for (int i = first_note; i < noteSet.Length; i++)
                {
                    bool             exit_loop      = false;
                    bool             ceaseExploding = false;
                    SongData.NoteSet n = noteSet[i];

                    // TODO: Total hack for end of project... should be using isHOPO instead.
                    bool isHopoNote = (noteSet[i].type & (((ulong)1) << 5)) != 0;
                    for (ulong k = 1, trueId = 0; k <= noteSet[i].type; k *= 2, trueId++)
                    {
                        ulong id = noteSet[i].type & k;
                        if (id == 0 || trueId > 4)
                        {
                            continue;
                        }
                        id = trueId;

                        float y = (float)(n.time - notes.SongTime.TotalMilliseconds) / 500f - 2.3f;
                        float x = (float)(-0.6 + id * 0.3);

                        if (y > 3)
                        {
                            exit_loop = true;
                            break;
                        }

                        if (y < -4 && ((n.length / 500f) + y) < -4)
                        {
                            if (notes.SongTime.TotalMilliseconds > 0.0)
                            {
                                first_note = i;
                            }
                            break;
                        }

                        if (n.length > 0)
                        {
                            //GraphicsDevice.VertexDeclaration = textureDeclaration; // 4.0change
                            longEffect.World = Matrix.Identity * Matrix.CreateScale(0.1f, 1.0f, 1.0f) *
                                               Matrix.CreateTranslation(x, y, 0.0f) * Matrix.CreateRotationX(rotation);

                            if ((n.burning & k) == 0 && (n.visible[id] == SongData.NoteSet.VIS_STATE.VISIBLE || !n.HasStrummed()))
                            {
                                longEffect.Texture = long_note_color;

                                float long_end = n.length / 500f;

                                // btftest
                                long_note[0] = new VertexPositionTexture(new Vector3(-1, long_end, 0.015f), new Vector2(0, 0));
                                long_note[1] = new VertexPositionTexture(new Vector3(1, long_end, 0.015f), new Vector2(1, 0));
                                long_note[2] = new VertexPositionTexture(new Vector3(-1, 0f, 0.015f), new Vector2(0, 1));
                                long_note[3] = new VertexPositionTexture(new Vector3(1, 0f, 0.015f), new Vector2(1, 1));

                                // Begin effect and draw for each pass
                                //longEffect.Begin();
                                foreach (EffectPass pass in longEffect.CurrentTechnique.Passes)
                                {
                                    pass.Apply();

                                    /*GraphicsDevice.DrawUserPrimitives<VertexPositionTexture>
                                     * (PrimitiveType.TriangleFan, long_note, 0, 2);
                                     * pass.End();*/
                                    // 4.0change
                                    GraphicsDevice.DrawUserPrimitives <VertexPositionTexture>
                                        (PrimitiveType.TriangleStrip, long_note, 0, 2); // 4.0change: strip or list? Include long_note?
                                }
                                //longEffect.End();
                            }
                        }

                        if (n.visible[id] == SongData.NoteSet.VIS_STATE.INVISIBLE)
                        {
                            if ((n.exploding & k) != 0)
                            {
                                explosion.AddParticles(new Vector2(260 + 70 * id, 520), GetDefaultColor(id));
                                ceaseExploding = true;
                            }
                            continue;
                        }

                        if (isHopoNote)
                        {
                            foreach (ModelMesh mesh in hopoModels[id].Meshes)
                            {
                                foreach (BasicEffect be in mesh.Effects)
                                {
                                    be.EnableDefaultLighting();
                                    be.Projection = projection;
                                    be.View       = view;
                                    be.World      = Matrix.Identity * Matrix.CreateRotationX(1.6f) * mesh.ParentBone.Transform *
                                                    Matrix.CreateScale(0.2f) * Matrix.CreateTranslation(x, y, 0) * Matrix.CreateRotationX(rotation);
                                }
                                mesh.Draw();
                            }
                        }
                        else
                        {
                            foreach (ModelMesh mesh in draw_notes[id].Meshes)
                            {
                                foreach (BasicEffect be in mesh.Effects)
                                {
                                    be.EnableDefaultLighting();
                                    be.Projection = projection;
                                    be.View       = view;
                                    be.World      = Matrix.Identity * Matrix.CreateRotationX(1.6f) * mesh.ParentBone.Transform *
                                                    Matrix.CreateScale(0.2f) * Matrix.CreateTranslation(x, y, 0) * Matrix.CreateRotationX(rotation);
                                }
                                mesh.Draw();
                            }
                        }
                    }
                    if (ceaseExploding)
                    {
                        n.exploding = 0L;
                    }
                    if (exit_loop)
                    {
                        break;
                    }
                }
            }
        }