예제 #1
0
        public void Initialize(System.Windows.Forms.Form form)
        {
            if (isInitialized)
            {
                return;
            }

            idPool     = new Stratum.IdPool();
            sceneGraph = new Stratum.SceneGraph();

            BootstrapSharpDX(form);

            renderer = new Stratum.Renderer();

            var earth      = CreateGameObject();
            var planetComp = CreateComponent <PlanetComponent>();
            var atmosphere = CreateComponent <Atmosphere>();

            earth.AddComponent(planetComp);
            earth.AddComponent(atmosphere);
            SceneGraph.Insert(earth, null);

            Engine.GraphicsContext.CurrentCamera = new PlanetCamera(RenderWGS84.EarthRadius);

            //worldEngine = new World();
            //Engine.Instance.AddService(worldEngine, typeof(IWorldEngine), typeof(World));

            isInitialized = true;
        }
예제 #2
0
        internal static void Delete(Component component)
        {
            IdPool.Free(component.Id);

            component.Delete();

            Component o;

            components.TryRemove(component.Id, out o);
        }
예제 #3
0
        public static T CreateComponent <T>() where T : Component
        {
            ulong id        = IdPool.Get();
            T     component = Activator.CreateInstance <T>();

            component.Id = id;

            // add component to Engine
            components[id] = component;

            return(component);
        }
예제 #4
0
        public static GameObject CreateGameObject()
        {
            ulong      id      = IdPool.Get();
            GameObject @object = new GameObject();

            @object.Id = id;

            // add object to Engine
            objects[id] = @object;

            return(@object);
        }
예제 #5
0
        internal static void Delete(SceneNode sceneNode)
        {
            IdPool.Free(sceneNode.Id);

            sceneNode.Delete();

            GameObject o;

            objects.TryRemove(sceneNode.Id, out o);

            foreach (var child in sceneNode.Children)
            {
                Delete(child);
            }
        }