/// <summary> /// The main setup point for the initial scene graph and tools /// </summary> public void SetupInitialObjects() { Root = new MObject(MObject.EType.Null, "Root"); //Root.Deletable = false; TemplateRoot = new MObject(MObject.EType.Null, "TemplateRoot"); Root.Add(TemplateRoot); TemplateRoot.Enabled = false; //disable updates SelectionRoot = new MObject(MObject.EType.Null, "Selection"); Root.Add(SelectionRoot); UtilityRoot = new MObject(MObject.EType.Null, "Utility"); UtilityRoot.Deletable = false; Root.Add(UtilityRoot); time = new Time(); UtilityRoot.Add(time); LightRoot = new MObject(MObject.EType.Null, "LightRoot"); Root.Add(LightRoot); Globals.ScriptHost = new MScriptHost(); UtilityRoot.Add(Globals.ScriptHost); MSystemScript sc = new MSystemScript("Massive.Main", Root); sc.SetActivator(Globals.ScriptHost.GetMainActivator()); Root.Add(sc); Globals.TexturePool = new TexturePool(); UtilityRoot.Add(Globals.TexturePool); Renderer = new MRenderer(); UtilityRoot.Add(Renderer); DefaultShader = new MShader(MShader.DEFAULT_SHADER); DefaultShader.Load("default_v.glsl", "default_f.glsl", "Terrain\\eval.glsl", "Terrain\\control.glsl"); DefaultShader.Bind(); DefaultShader.SetInt("material.diffuse", MShader.LOCATION_DIFFUSE); DefaultShader.SetInt("material.specular", MShader.LOCATION_SPECULAR); DefaultShader.SetInt("material.multitex", MShader.LOCATION_MULTITEX); DefaultShader.SetInt("material.normalmap", MShader.LOCATION_NORMALMAP); DefaultShader.SetInt("material.shadowMap", MShader.LOCATION_SHADOWMAP); //DefaultShader.Deletable = false; Helper.CheckGLError(this, "TestPoint 1"); // MShader GUIShader = new MShader("DefaultGUIShader"); // GUIShader.Load("gui_v.glsl", "gui_f.glsl"); //GUIShader.Bind(); //GUIShader.Deletable = false; MaterialRoot = new MObject(MObject.EType.Null, "MaterialRoot"); //MaterialRoot.Deletable = false; Root.Add(MaterialRoot); Helper.CheckGLError(this); if (Physics != null) { Physics.Dispose(); } Physics = new MPhysics(); Physics.Setup(); //only need to do this once //Physics.Deletable = false; UtilityRoot.Add(Physics); Helper.CheckGLError(this, "TestPoint 2"); //UtilityRoot.Add(Globals.Network); //Globals.Network.Deletable = false; DistanceClipper = new MDistanceClipper(); UtilityRoot.Add(DistanceClipper); FrustrumCuller = new MFrustrumCuller(); UtilityRoot.Add(FrustrumCuller); Globals.Avatar = new MAvatar("Player1"); UtilityRoot.Add(Globals.Avatar); Background = new MObject(MObject.EType.Null, "Background"); Root.Add(Background); Background2 = new MObject(MObject.EType.Null, "Background2"); Root.Add(Background2); ModelRoot = new MObject(MObject.EType.Null, "ModelRoot"); Root.Add(ModelRoot); ModelRoot.Deletable = false; AstroRoot = new MObject(MObject.EType.Null, "AstroRoot"); //ModelRoot.Add(AstroRoot); UtilityRoot.Add(AstroRoot); AstroRoot.Deletable = false; if (Settings.DrawPlanets == true) { MPlanetHandler mpi = new MPlanetHandler(); UtilityRoot.Add(mpi); MGrass grass = new MGrass(); Background2.Add(grass); } Priority1 = new MObject(MObject.EType.Null, "Priority1"); ModelRoot.Add(Priority1); Priority2 = new MObject(MObject.EType.Null, "Priority2"); ModelRoot.Add(Priority2); Overlay = new MObject(MObject.EType.Null, "Overlay"); //ModelRoot.Add(Overlay); //manually drawn in render if (Settings.DrawBackdrop == true) { AddBackdrop(); } Fog = new MFog(); UtilityRoot.Add(Fog); DefaultMaterial = new MMaterial(MMaterial.DEFAULT_MATERIAL); DefaultMaterial.Deletable = false; DefaultMaterial.AddShader(DefaultShader); //DefaultMaterial.SetDiffuseTexture(Globals.TexturePool.GetTexture("Textures\\default.jpg")); MaterialRoot.Add(DefaultMaterial); MTexture DefaultTexture = new MTexture(MTexture.DEFAULT_TEXTURE); DefaultTexture.LoadTextureData(MFileSystem.ProjectPath + "Assets\\Textures\\default.jpg"); DefaultTexture.DoAssign = true; DefaultMaterial.SetDiffuseTexture(DefaultTexture); MMaterial GUIMat = new MMaterial("DefaultGUIMaterial"); //GUIMat.Deletable = false; //GUIMat.AddShader(GUIShader); //GUIMat.SetDiffuseTexture(Globals.TexturePool.GetTexture("Textures\\unwrap_helper_1024.jpg")); //MaterialRoot.Add(GUIMat); MMaterial DepthMaterial = new MMaterial("Depth"); DepthMaterial.Deletable = false; simpleDepthShader = new MShader("simpleDepthShader"); simpleDepthShader.Load("shadow_mapping_depth_v.glsl", "shadow_mapping_depth_f.glsl", "", "") ; DepthMaterial.shader = simpleDepthShader; DepthMaterial.Add(simpleDepthShader); MaterialRoot.Add(DepthMaterial); Helper.CheckGLError(this, "TestPoint 5"); //UtilityRoot.Add(audioListener); //audioListener.Deletable = false; Camera = new MCamera("MainCam"); Camera.OwnerID = MObject.OWNER_SYSTEM; Camera.transform.Position = new Vector3d(9, 5, 9); UtilityRoot.Add(Camera); audioListener = new MAudioListener(); Camera.Add(audioListener); // Camera.Deletable = false; light = new MLight("DirLight"); light.OwnerID = MObject.OWNER_SYSTEM; light.transform.Position = new Vector3d(-10, 20.0f, -10.0f); UtilityRoot.Add(light); //light.Deletable = false; ScreenPick = new MScreenPick(); // ScreenPick.Setup(); UtilityRoot.Add(ScreenPick); // ScreenPick.Deletable = false; MShader debugDepthQuad = new MShader("debugDepthQuad"); debugDepthQuad.Load("debug_quad_v.glsl", "debug_quad_f.glsl", "Terrain\\eval.glsl", "Terrain\\control.glsl"); debugDepthQuad.Bind(); debugDepthQuad.SetInt("depthMap", 0); //debugDepthQuad.SetFloat("near_plane", light.NearPlane); //debugDepthQuad.SetFloat("far_plane", light.FarPlane); UtilityRoot.Add(debugDepthQuad); debugDepthQuad.Deletable = false; MMaterial debugmat = new MMaterial("DEBUG"); debugmat.shader = debugDepthQuad; //debugmat.Deletable = false; debugQuad = new DebugQuad("DEBUGQUAD"); debugQuad.material = debugmat; UtilityRoot.Add(debugQuad); debugQuad.Deletable = false; GUIRoot = new MGUI(); Root.Add(GUIRoot); Helper.CheckGLError(this, "TestPoint 6"); }
public MPlanetHandler() : base(MObject.EType.Null, "Planet") { _Instance = this; }