public void Draw(SceneRenderer renderer)
        {
            for (int row = 1; row <= fRowsCount; row++)
            {
                for (int col = 1; col <= fColsCount; col++)
                {
                    Vector3D normal;
                    normal.Z = fCells[row - 1, col].Y - fCells[row + 1, col].Y;
                    normal.X = fCells[row, col - 1].Y - fCells[row, col + 1].Y;
                    normal.Y = 4;
                    fNormals[row - 1, col - 1] = normal;
                }
            }

            renderer.SetMaterial(Water2Diffuse, Water2Specular, Water2Shininess);

            for (int row = 1; row <= fRowsCount - 1; row++)
            {
                renderer.BeginTriangleStrip();

                for (int col = 1; col <= fColsCount; col++)
                {
                    float xx, yy, zz;
                    xx = fBoundingBox.XMin + (col - 1) * fCellStep;

                    var nrm = fNormals[row - 1, col - 1];
                    renderer.Normal3f(nrm.X, nrm.Y, nrm.Z);

                    yy = fBoundingBox.YMin + fCells[row, col].Y / 1000;
                    zz = fBoundingBox.ZMin + (row - 1) * fCellStep;
                    renderer.Vertex3f(xx, yy, zz);

                    nrm = fNormals[row, col - 1];
                    renderer.Normal3f(nrm.X, nrm.Y, nrm.Z);

                    yy = fBoundingBox.YMin + fCells[row + 1, col].Y / 1000;
                    zz = fBoundingBox.ZMin + (row + 0) * fCellStep;
                    renderer.Vertex3f(xx, yy, zz);
                }

                renderer.End();
            }
        }
Beispiel #2
0
        public void DrawBubbles(SceneRenderer renderer, Point3D aeratorPt, float waterHeight, IList <M3DBubble> surfacedBubbles)
        {
            renderer.Color4f(1.0f, 1.0f, 1.0f, 0.45f);

            foreach (M3DBubble bubble in fBubbles)
            {
                bool isSurfaced;
                Update(bubble, waterHeight, out isSurfaced);
                if (isSurfaced)
                {
                    if (surfacedBubbles != null)
                    {
                        var surfBubble = bubble.Clone();
                        surfacedBubbles.Add(surfBubble);
                    }
                    Init(bubble);
                }

                var bblPt = aeratorPt.Add(bubble.X, bubble.Y, bubble.Z);
                renderer.DrawSphere(bblPt, bubble.Size, 16, 16);
            }
        }