public static void onActivateBasicLM() { Torque3D.PostEffect HDRPostFx = Sim.FindObjectByName <Torque3D.PostEffect>("HDRPostFx"); // If HDR is enabled... enable the special format token. if (!Globals.GetString("platform").Equals("macos") && HDRPostFx.isEnabled()) { Core.RenderManager.AL_FormatToken.enable(); } // Create render pass for projected shadow. BL_ProjectedShadowRPM = new RenderPassManager("BL_ProjectedShadowRPM"); BL_ProjectedShadowRPM.registerObject(); // Create the mesh bin and add it to the manager. RenderMeshMgr meshBin = new RenderMeshMgr(); meshBin.registerObject(); BL_ProjectedShadowRPM.addManager(meshBin); SimGroup RootGroup = Sim.FindObjectByName <SimGroup>("RootGroup"); // Add both to the root group so that it doesn't // end up in the MissionCleanup instant group. RootGroup.add(BL_ProjectedShadowRPM); RootGroup.add(meshBin); }
public void deleteMat() { SimSet TerrainMaterialSet = "TerrainMaterialSet"; SimGroup TerrainMaterialDlgDeleteGroup = "TerrainMaterialDlgDeleteGroup"; TerrainEditor ETerrainEditor = "ETerrainEditor"; if (!this["activeMat"].isObject()) { return; } // Cannot delete this material if it is the only one left on the Terrain if ((ETerrainEditor.getMaterialCount() == 1) && ETerrainEditor.getMaterialIndex(((SimObject)this["activeMat"]).internalName) != -1) { messageBox.MessageBoxOK("Error", "Cannot delete this Material, it is the only Material still in use by the active Terrain."); return; } TerrainMaterialSet.remove(this["activeMat"]); TerrainMaterialDlgDeleteGroup.add(this["activeMat"]); GuiTreeViewCtrl matLibTree = this.findObjectByInternalName("matLibTree", true); buildTree(); //matLibTree.open("TerrainMaterialSet", false); //matLibTree.selectItem(1); }
//----------------------------------------------------------------------------- // Called when all datablocks have been transmitted. public void onEnterGame() { //TODO should this be pClient //GameConnection client = Sim.FindObject<GameConnection>(pClient); // Create a camera for the client. Camera theCamera = new Camera("TheCamera") { DataBlock = Sim.FindObjectByName <CameraData>("Observer") }; theCamera.registerObject(); theCamera.setTransform(new TransformF(new Point3F(0, 0, 2), new AngAxisF(1, 0, 0, 0))); // Cameras are not ghosted (sent across the network) by default; we need to // do it manually for the client that owns the camera or things will go south // quickly. theCamera.scopeToClient(this); // And let the client control the camera. setControlObject(theCamera); // Add the camera to the group of game objects so that it's cleaned up when // we close the game. SimGroup gameGroup = Sim.FindObject <SimGroup>("GameGroup"); gameGroup.add(theCamera); // Activate HUD which allows us to see the game. This should technically be // a commandToClient, but since the client and server are on the same // machine... GuiCanvas canvas = Sim.FindObject <GuiCanvas>("Canvas"); canvas.setContent(Sim.FindObject <GuiTSCtrl>("PlayGui")); Global.activateDirectInput(); }
/// <summary> /// Create a server of the given type, load the given level, and then /// create a local client connection to the server. /// </summary> /// <param name="serverType"></param> /// <param name="level"></param> /// <returns>true if succesful.</returns> public static bool createAndConnectToLocalServer(string serverType, string level) { if (!createServer(serverType, level)) { return(false); } GameConnectionToServer ServerConnection = new GameConnectionToServer("ServerConnection", true); SimGroup RootGroup = Sim.FindObject <SimGroup>("RootGroup"); RootGroup.add(ServerConnection); ServerConnection.setConnectArgs(Globals.GetString("pref::Player::Name")); ServerConnection.setJoinPassword(Globals.GetString("Client::Password")); string result = ServerConnection.connectLocal(); if (!string.IsNullOrEmpty(result)) { ServerConnection.delete(); destroyServer(); return(false); } return(true); }
//---------------------------------------------------------------------------- // Helper functions //---------------------------------------------------------------------------- public static void connect(string server) { GameConnectionToServer conn = new GameConnectionToServer("ServerConnection", true); SimGroup RootGroup = Sim.FindObject <SimGroup>("RootGroup"); RootGroup.add(conn); conn.setConnectArgs(Globals.GetString("pref::Player::Name")); conn.setJoinPassword(Globals.GetString("Client::Password")); conn.connect(server); }
public void dialogApply() { SimGroup TerrainMaterialDlgNewGroup = "TerrainMaterialDlgNewGroup"; SimGroup TerrainMaterialDlgDeleteGroup = "TerrainMaterialDlgDeleteGroup"; PersistenceManager ETerrainMaterialPersistMan = "ETerrainMaterialPersistMan"; TerrainPainter TerrainPainter = "TerrainPainter"; SimGroup RootGroup = "RootGroup"; TerrainEditor ETerrainEditor = "ETerrainEditor"; // Move all new materials we have created to the root group. int newCount = TerrainMaterialDlgNewGroup.getCount(); for (uint i = 0; i < newCount; i++) { RootGroup.add(TerrainMaterialDlgNewGroup.getObject(i)); } // Finalize deletion of all removed materials. int deletedCount = TerrainMaterialDlgDeleteGroup.getCount(); for (uint i = 0; i < deletedCount; i++) { SimObject mat = TerrainMaterialDlgDeleteGroup.getObject(i); ETerrainMaterialPersistMan.removeObjectFromFile(mat); int _matIndex = ETerrainEditor.getMaterialIndex(mat.internalName); if (_matIndex != -1) { ETerrainEditor.removeMaterial(matIndex); TerrainPainter.updateLayers(""); } mat.delete(); } // Make sure we save any changes to the current selection. saveDirtyMaterial(this["activeMat"]); // Save all changes. ETerrainMaterialPersistMan.saveDirty(); // Delete the snapshot. "TerrainMaterialDlgSnapshot".delete(); ((GuiCanvas)"Canvas").popDialog(this); Util._call(onApplyCallback, this["activeMat"], this.matIndex.AsString()); }
public static void onStart() { // Create objects! SimGroup gameGroup = new SimGroup("GameGroup"); gameGroup.Name = "GameGroup"; gameGroup.registerObject(); LevelInfo levelInfo = new LevelInfo("TheLevelInfo") { CanvasClearColor = new ColorI(0, 0, 0, 0) }; levelInfo.registerObject(); GroundPlane groundPlane = new GroundPlane("TheGround") { Position = Point3F.Zero, Material = "BlankWhite" }; groundPlane.registerObject(); Sun sun = new Sun("TheSun") { Azimuth = 230, Elevation = 45, Color = ColorF.WHITE, Ambient = new ColorF(0.1f, 0.1f, 0.1f, 1), CastShadows = true }; sun.registerObject(); gameGroup.add(levelInfo, groundPlane, sun); // Allow us to exit the game... ActionMap globalActionMap = Sim.FindObjectByName <ActionMap>("GlobalActionMap"); globalActionMap.bindCmd("keyboard", "escape", "quit"); }