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
| public bool Init()
{
Engine = new nxEngine();
Engine.SetGraphicsEngine(new GraphicsEngine(Engine));
if (Engine.Init() == false) return false;
Engine.OnUpdate += new OnEngineUpdate(Engine_OnUpdate);
Engine.OnRender += new OnEngineRender(Engine_OnRender);
CameraPivot Camera = new CameraPivot(new Vector3(0.0f, 5.0f, -20.0f), Vector3.Zero);
Camera.SetDefaultMappers();
DirectLight Light = new DirectLight(new Vector3(-1.0f, -1.0f, -1.0f));
Material ShipMaterial = new Material(Shader.FromFile("gouraud"));
ShipMaterial["AmbientColor"].Value = new Color(0.1f);
ShipMaterial["DiffuseColor"].Value = Color.White;
ShipMaterial["SpecularColor"].Value = Color.Gray;
ShipMaterial["SpecularPower"].Value = 64.0f;
Model ShipModel = Model.FromFile("af");
ShipModel.AddPart(ModelPart.FromModel(ShipModel));
ShipModel.Parts[0].AddMaterial(ShipMaterial);
BitmapFont Font = BitmapFont.FromFile("pr_font_32");
Font.Kerning = -5;
FpsLabel = new Label(Font, string.Empty, Color.White);
SceneGraph = new SceneGraph();
SceneGraph.AddEntity(Camera);
SceneGraph.AddEntity(Light);
SceneGraph.AddToRoot(ShipModel);
SceneGraph.AddToRoot(FpsLabel);
Engine.SceneEngine.AddSceneGraph(SceneGraph);
return true;
} |