Beispiel #1
0
        private void BuildTreeSpritesBuffers()
        {
            var v = new TreePointSprite[TreeCount];

            for (int i = 0; i < TreeCount; i++)
            {
                float y;
                float x;
                float z;
                do
                {
                    x = MathF.Rand(-75.0f, 75.0f);
                    z = MathF.Rand(-75.0f, 75.0f);
                    y = GetHillHeight(x, z);
                } while (y < -3 || y > 15.0f);
                y += 10.0f;

                v[i].Pos  = new Vector3(x, y, z);
                v[i].Size = new Vector2(24.0f, 24.0f);
            }
            var vbd = new BufferDescription {
                Usage          = ResourceUsage.Immutable,
                SizeInBytes    = TreePointSprite.Stride * TreeCount,
                BindFlags      = BindFlags.VertexBuffer,
                CpuAccessFlags = CpuAccessFlags.None,
                OptionFlags    = ResourceOptionFlags.None,
            };

            _treeSpritesVB = new Buffer(Device, new DataStream(v, false, false), vbd);
        }
Beispiel #2
0
        private void BuildTreeSpritesBuffers() {
            var v = new TreePointSprite[TreeCount];
            for (int i = 0; i < TreeCount; i++) {
                float y;
                float x;
                float z;
                do {
                    x = MathF.Rand(-75.0f, 75.0f);
                    z = MathF.Rand(-75.0f, 75.0f);
                    y = GetHillHeight(x, z);
                } while (y < -3 || y > 15.0f); 
                y += 10.0f;

                v[i].Pos = new Vector3(x,y,z);
                v[i].Size = new Vector2(24.0f,24.0f);
            }
            var vbd = new BufferDescription {
                Usage = ResourceUsage.Immutable,
                SizeInBytes = TreePointSprite.Stride * TreeCount,
                BindFlags = BindFlags.VertexBuffer,
                CpuAccessFlags = CpuAccessFlags.None,
                OptionFlags = ResourceOptionFlags.None,
            };
            _treeSpritesVB = new Buffer(Device, new DataStream(v, false, false), vbd);
        }