/
BoardObject.cs
56 lines (47 loc) · 1.71 KB
/
BoardObject.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DigitalRune.Game;
using DigitalRune.Graphics.SceneGraph;
using Microsoft.Practices.ServiceLocation;
using Microsoft.Xna.Framework.Content;
using DigitalRune.Graphics;
using ICT309Game.Graphics;
using Microsoft.Xna.Framework;
using DigitalRune.Graphics.Effects;
using DigitalRune.Mathematics.Algebra;
namespace ICT309Game.GameObjects
{
class BoardObject:GameObject
{
private ModelNode _model;
protected override void OnLoad()
{
Console.WriteLine("BoardObject OnLoad");
var contentManager = ServiceLocator.Current.GetInstance<ContentManager>();
var graphicsService = ServiceLocator.Current.GetInstance<IGraphicsService>();
var screen = ((GameScreen)graphicsService.Screens["Default"]);
_model = contentManager.Load<ModelNode>("testmodel");
_model = _model.Clone();
foreach (var meshNode in _model.GetSubtree().OfType<MeshNode>())
{
Mesh mesh = meshNode.Mesh;
foreach (var material in mesh.Materials)
{
var effectBinding = material["Default"];
effectBinding.Set("DiffuseColor", new Vector4(1.0f, 1.0f, 1.0f, 1));
((BasicEffectBinding)effectBinding).LightingEnabled = false;
}
}
screen.Scene.Children.Add(_model);
_model.PoseWorld = new DigitalRune.Geometry.Pose(new Vector3F(0.0f, 0.0f, 0.0f));
base.OnLoad();
}
protected override void OnUnload()
{
_model.Dispose();
base.OnUnload();
}
}
}