-
Notifications
You must be signed in to change notification settings - Fork 0
/
Menu.cs
118 lines (97 loc) · 3.45 KB
/
Menu.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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Color = Microsoft.Xna.Framework.Color;
using Matrix = Microsoft.Xna.Framework.Matrix;
using GoblinXNA;
using GoblinXNA.Graphics;
using GoblinXNA.SceneGraph;
using Model = GoblinXNA.Graphics.Model;
using GoblinXNA.Graphics.Geometry;
using GoblinXNA.Device.Generic;
using GoblinXNA.Device.Capture;
using GoblinXNA.Device.Vision;
using GoblinXNA.Device.Vision.Marker;
using GoblinXNA.Device.Util;
using GoblinXNA.Helpers;
using GoblinXNA.UI;
using GoblinXNA.UI.UI2D;
using Tutorial16___Multiple_Viewport;
using Curveball;
using Tutorial16___Multiple_Viewport___PhoneLib;
namespace Curveball
{
// The viewport and ground marker node comes from the container.
// This class only contains menu specific scene elements.
public class Menu
{
private Tutorial16_Phone _container;
GeometryNode overlayNode;
public Menu(Tutorial16_Phone container)
{
_container = container;
}
public void GotoLevel()
{
// What to do here:
// Halt the container update.
// Unmount itself. (Call this.Unmount().)
// Create a level with the information gathered.
// Mount the level. (Call level.Mount().)
// Set the state of the container.
// Resume container update.
}
public void Mount()
{
// Attach its elements to the scene graph in the container.
throw new NotImplementedException();
}
public void Unmount()
{
// Detach its elements from the scene graph in the container.
throw new NotImplementedException();
}
// Move the menu specific part of the scene graph from the
// container to this class
public void Initialize()
{
// Attach itself to the scene graph of the container.
// Create 3D objects
CreateObjects();
}
private void CreateObjects()
{
ModelLoader loader = new ModelLoader();
overlayNode = new GeometryNode("Overlay");
overlayNode.Model = (Model)loader.Load("", "p1_wedge");
((Model)overlayNode.Model).UseInternalMaterials = true;
// Get the dimension of the model
Vector3 dimension = Vector3Helper.GetDimensions(overlayNode.Model.MinimumBoundingBox);
// Scale the model to fit to the size of 5 markers
float scale = 100 / Math.Max(dimension.X, dimension.Z);
TransformNode overlayTransNode = new TransformNode()
{
Translation = new Vector3(0, 0, dimension.Y * scale / 2),
Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitX, MathHelper.ToRadians(90)) *
Quaternion.CreateFromAxisAngle(Vector3.UnitY, MathHelper.ToRadians(90)),
Scale = new Vector3(scale, scale, scale)
};
_container.OverlayRoot.AddChild(overlayTransNode);
overlayTransNode.AddChild(overlayNode);
}
public void Update()
{
}
public void Return()
{
// Called when returning from level.
}
}
}