GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Silverback/LevelEditor/Engine/Grass.cs at master · SilverbackSoPra/Silverback

Expand file tree

/

Grass.cs

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
96 lines (74 loc) · 2.9 KB
/

Grass.cs

Copy path

File metadata and controls

96 lines (74 loc) · 2.9 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using LevelEditor.Engine.Helper;
using Microsoft.Xna.Framework;
namespace LevelEditor.Engine
{
public class Grass
{
public const int GrassPatchSize = 4;
public const int GrassPatchInstancesCount = 25;
public class Patch
{
public Vector3 mPosition;
public int mPatchInstancesOffset;
public float mRadius = (float)Math.Sqrt(2.0 * Math.Pow(GrassPatchSize / 2.0, 2.0));
public float mDistance;
public float mSlope;
public bool mRender;
public Patch(Vector3 position, int patchInstancesOffset)
{
mPosition = position;
mPatchInstancesOffset = patchInstancesOffset;
mDistance = 0.0f;
mRender = true;
}
public void Generate(Terrain terrain, GrassInstancing[] instances, Random random)
{
mSlope = terrain.GetSlope(mPosition);
for (var i = 0; i < GrassPatchInstancesCount; i++)
{
var x = 2.0f * (float)random.NextDouble() - 1.0f;
var z = 2.0f * (float)random.NextDouble() - 1.0f;
var position = new Vector3(x, 0.0f, z) * GrassPatchSize / 2.0f + mPosition;
position.Y = terrain.GetHeight(position);
instances[mPatchInstancesOffset + i].Position = position;
}
}
}
public GrassInstancing[] mGrassInstances;
public Patch[] mPatches;
public bool mActivated;
private Terrain mTerrain;
private Random mRandom = new Random();
public Grass(Terrain terrain)
{
mActivated = true;
var patchesPerLine = terrain.Size / GrassPatchSize;
mGrassInstances = new GrassInstancing[patchesPerLine * patchesPerLine * GrassPatchInstancesCount];
mTerrain = terrain;
mPatches = new Patch[patchesPerLine * patchesPerLine];
for (var i = 0; i < patchesPerLine; i++)
{
for (var j = 0; j < patchesPerLine; j++)
{
var position = new Vector3(i * GrassPatchSize + GrassPatchSize / 2.0f - 128.0f, 0.0f, j * GrassPatchSize + GrassPatchSize / 2.0f - 128.0f);
var offset = (i * patchesPerLine + j) * GrassPatchInstancesCount;
position.Y = mTerrain.GetHeight(position);
mPatches[i * patchesPerLine + j] = new Patch(position, offset);
}
}
}
public void Generate()
{
foreach (var patch in mPatches)
{
patch.Generate(mTerrain, mGrassInstances, mRandom);
}
}
}
}
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.