-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ground.cs
70 lines (59 loc) · 1.93 KB
/
Ground.cs
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
using Mogre;
using Mogre.TutorialFramework;
using System;
namespace Mogre.Tutorial
{
/// <summary>
/// This class implements the ground of the environment
/// </summary>
class Ground : StaticElement
{
Plane plane;
Entity groundEntity;
SceneNode groundNode;
public Plane Plane
{
get { return plane; }
}
int groundWidth = 10;
int groundHeight = 10;
int groundXSegs = 100;
int groundZSegs = 100;
int uTiles = 10;
int vTiles = 10;
/// <summary>
/// Constructor
/// </summary>
/// <param name="mSceneMgr">A reference of the scene manager</param>
public Ground(SceneManager mSceneMgr)
{
this.mSceneMgr = mSceneMgr;
groundWidth = 1000;
groundHeight = 1000;
CreateGround();
}
/// <summary>
/// This method initializes the ground mesh and its node
/// </summary>
private void CreateGround()
{
GroundPlane();
}
/// <summary>
/// This method generates a plane in an Entity which will be used as a ground
/// </summary>
private void GroundPlane()
{
plane = new Plane(Vector3.UNIT_Y, 0);
MeshPtr groundMeshPtr = MeshManager.Singleton.CreatePlane("ground",
ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, plane, groundWidth,
groundHeight, groundXSegs, groundZSegs, true, 1, uTiles, vTiles,
Vector3.UNIT_Z);
groundEntity = mSceneMgr.CreateEntity("ground");
groundNode = mSceneMgr.CreateSceneNode();
groundNode.AttachObject(groundEntity);
mSceneMgr.RootSceneNode.AddChild(groundNode);
groundEntity.SetMaterialName("Meteor");
}
}
}