예제 #1
0
        /// <summary>
        /// Create and return a new SimScene from this definition.
        /// </summary>
        /// <returns>A new scene configured like this definition.</returns>
        public SimScene createScene()
        {
            SimScene scene = new SimScene();

            foreach (SimElementManagerDefinition elementManagerDef in elementManagers)
            {
                scene.addSimElementManager(elementManagerDef.createSimElementManager());
            }
            foreach (SimSubSceneDefinition subSceneDef in subSceneDefinitions.Values)
            {
                subSceneDef.createSubScene(scene);
            }
            if (DefaultSubScene != null)
            {
                SimSubScene subScene = scene.getSubScene(DefaultSubScene);
                if (subScene != null)
                {
                    scene.setDefaultSubScene(subScene);
                }
                else
                {
                    Log.Default.sendMessage("The defined default scene {0} can not be found in the created scene. No default set.", LogLevel.Warning, "Engine", DefaultSubScene);
                }
            }
            else
            {
                Log.Default.sendMessage("No default scene defined. No default set.", LogLevel.Warning, "Engine");
            }
            return(scene);
        }
예제 #2
0
        /// <summary>
        /// Register with factories to build this definition into the given SimObject.
        /// </summary>
        /// <param name="instance">The SimObject that will get the built elements.</param>
        public SimObjectBase register(SimSubScene subScene)
        {
            SimObjectBase instance = new GenericSimObject(name, Translation, Rotation, Scale, Enabled);

            foreach (SimElementDefinition definition in definitions)
            {
                definition.registerScene(subScene, instance);
            }
            return(instance);
        }
예제 #3
0
        /// <summary>
        /// Returns a new SimObjectManager that contains all the SimObjects
        /// defined in this class. The SimObjects will be empty, but they will
        /// be registered for construction.
        /// </summary>
        /// <param name="subScene">The SimSubScene that will be used to build the objects in the returned manager.</param>
        /// <returns>A new SimObjectManager that contains empty SimObjects ready to be built into the given SimSubScene.</returns>
        public SimObjectManager createSimObjectManager(SimSubScene subScene)
        {
            SimObjectManager manager = new SimObjectManager(subScene);

            foreach (SimObjectDefinition instance in simObjects.Values)
            {
                SimObjectBase simObject = instance.register(subScene);
                manager.addSimObject(simObject);
            }
            return(manager);
        }
예제 #4
0
 /// <summary>
 /// Set the default SimSubScene. The SimSubScene passed to this function
 /// must have already been added to this SimScene. If this is not
 /// correct the log will report the error.
 /// </summary>
 /// <param name="scene">The scene to set as the default.</param>
 public void setDefaultSubScene(SimSubScene scene)
 {
     if (simSubScenes.ContainsKey(scene.Name))
     {
         defaultScene = scene;
     }
     else
     {
         Log.Default.sendMessage("Attempted to set the scene {0} as the default to the SimScene that is not part of the scene. This has not been set as the default.", LogLevel.Warning, "Engine", scene.Name);
     }
 }
 public override void registerScene(Engine.ObjectManagement.SimSubScene subscene, Engine.ObjectManagement.SimObjectBase instance)
 {
     if (subscene.hasSimElementManagerType(typeof(BulletScene)))
     {
         BulletScene sceneManager = subscene.getSimElementManager <BulletScene>();
         sceneManager.getBulletFactory().addTypedConstraint(this, instance);
     }
     else
     {
         Logging.Log.Default.sendMessage("Cannot add PhysActorDefinition {0} to SimSubScene {1} because it does not contain a BulletSceneManager.", Logging.LogLevel.Warning, BulletInterface.PluginName, Name, subscene.Name);
     }
 }
예제 #6
0
        /// <summary>
        /// Create a new SimSubScene and add it to scene.
        /// </summary>
        /// <param name="scene">The scene to add the sub scene to.</param>
        /// <returns>The newly created sub scene.</returns>
        public SimSubScene createSubScene(SimScene scene)
        {
            SimSubScene subscene = new SimSubScene(Name, scene);

            foreach (SimSubSceneBinding elementManager in bindings)
            {
                SimElementManager manager = scene.getSimElementManager(elementManager.SimElementManager.Name);
                if (manager != null)
                {
                    subscene.addSimElementManager(manager);
                }
                else
                {
                    Log.Default.sendMessage("Could not find SimElementManager called {0}. This has not been added to the scene.", LogLevel.Warning, "Engine", elementManager);
                }
            }
            scene.addSimSubScene(subscene);
            return(subscene);
        }
 /// <summary>
 /// Register this element with its factory so it can be built.
 /// </summary>
 /// <param name="subscene">The SimSubScene that will get the built product.</param>
 /// <param name="instance">The SimObject that will get the newly created element.</param>
 public abstract void registerScene(SimSubScene subscene, SimObjectBase instance);
예제 #8
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="subScene">The SubScene that owns the objects.</param>
 public SimObjectManager(SimSubScene subScene)
 {
     this.subScene = subScene;
 }
예제 #9
0
 /// <summary>
 /// Add a SimSubScene.
 /// </summary>
 /// <param name="scene">The SimSubScene to add.</param>
 public void addSimSubScene(SimSubScene scene)
 {
     this.simSubScenes.Add(scene.Name, scene);
 }
예제 #10
0
 /// <summary>
 /// Remove a SimSubScene.
 /// </summary>
 /// <param name="scene">The scene to remove.</param>
 public void removeSimSubScene(SimSubScene scene)
 {
     this.simSubScenes.Remove(scene.Name);
 }