Beispiel #1
0
        private EActor FindActorParentInChildren(EActor target)
        {
            // DFS getting the parent
            // Search all scene
            for (int i = 0; i < EEngine.instance.loadScene.Count; i++)
            {
                EScene sceneBuffer = EEngine.instance.loadScene[i];
                if (sceneBuffer == null)
                {
                    continue;
                }

                // If scene have one more root objects
                if (sceneBuffer.childLength > 0)
                {
                    // Loop each object in scene root
                    for (int j = 0; j < sceneBuffer.GetChild(j).childLength; j++)
                    {
                        EActor current = sceneBuffer.GetChild(j);

                        // If the target is exist in the looping child
                        if (current.ExistInChild(target))
                        {
                            // Get the path to the target
                            EActor[] path = current.GetPathToChild(target);

                            for (int k = 0; k < path.Length; k++)
                            {
                                // Previous one is the parent
                                if (path[k] == target)
                                {
                                    return(path[k - 1]);
                                }
                            }
                        }
                    }
                }
            }

            return(null);
        }
Beispiel #2
0
        public static EScene GetDefaultScene()
        {
            EMaterial e = new EColorMat();
            // Empty scene
            EScene buffer = new EScene();

            // Add render stuff 03
            EActor obj = new EActor("floor");

            obj.position = new Vector3(0, -0.1f, 0);
            obj.scale    = new Vector3(20f, 20f, 20f);

            EMeshFilter meshf = obj.AddComponent <EMeshFilter>();

            meshf.SetMesh(EPrimitiveMesh.GetPrimitiveMesh(EPrimitiveMesh.PrimitiveType.Plane));

            EMeshRenderer meshr = obj.AddComponent <EMeshRenderer>();

            meshr.SetMaterial(e);
            buffer.AddActorToScene(obj);

            return(buffer);
        }
Beispiel #3
0
        public EWindow(int width, int height) : base(width, height, new GraphicsMode(32, 0, 0, 4), "Ellyality Demo")
        {
            GLWidth  = width;
            GLHeight = height;

            // Initialize the engine
            EEngine.Initialize();
            VSync = VSyncMode.Off;

            // Loading the asset into database
            EEngine.instance.assetDatabase = EAssetDatabase.Load();

            // Check if the loading successfully
            if (EAssetDatabase.GetResult().flag == LoadingResultFlag.FolderNotExist)
            {
                ELogger.Log(ELogger.LogType.Warning, ELoggerTag.Initialize, "Missing project folder");
                EAssetDatabase.CreateFolderStructure();
                EErrorReport.ExportReport(ELogger.GetLoggerMessage());
                Exit();
            }

            if (EAssetDatabase.GetResult().flag == LoadingResultFlag.Failed)
            {
                ELogger.Log(ELogger.LogType.Error, ELoggerTag.Initialize, "Loading asset failed");
                EErrorReport.ExportReport(ELogger.GetLoggerMessage());
                Exit();
            }

            // Loading the setting file into engine
            EEngine.instance.setting = EGameSetting.Loading();

            // Check if the loading successfully
            if (EGameSetting.GetResult().flag == LoadingResultFlag.FileNotExist)
            {
                ELogger.Log(ELogger.LogType.Warning, ELoggerTag.Initialize, "Missing project files");
                EGameSetting.CreateDefaultSetting();
                EErrorReport.ExportReport(ELogger.GetLoggerMessage());
                Exit();
            }

            if (EGameSetting.GetResult().flag == LoadingResultFlag.Failed)
            {
                ELogger.Log(ELogger.LogType.Error, ELoggerTag.Initialize, "Loading setting failed");
                EGameSetting.CreateDefaultSetting();
                EErrorReport.ExportReport(ELogger.GetLoggerMessage());
                Exit();
            }

            // If there is no scene has select
            // Create an empty scene for engine drawing
            if (EEngine.instance.setting.FirstLoadingScene == null || EEngine.instance.setting.FirstLoadingScene == "")
            {
                EEngine.instance.loadScene.Add(EScene.GetDefaultScene());
                ELogger.Log(ELogger.LogType.Warning, ELoggerTag.Initialize, "Default scene setting is null ! loading default scene instead...");
            }

            // Hide console window
            var handle = GetConsoleWindow();

            ShowWindow(handle, EEngine.instance.setting.DebugMode ? SW_SHOW : SW_HIDE);

            ELogger.Log(ELogger.LogType.Warning, ELoggerTag.Initialize, "Application fixed update rate: " + EEngine.instance.setting.FixedUpdateTime.ToString());
            ELogger.Log(ELogger.LogType.Warning, ELoggerTag.Initialize, "Application frame fresh rate: " + (double)1 / (double)EEngine.instance.setting.FramePreSecond);
            Run(EEngine.instance.setting.FixedUpdateTime, (double)1 / (double)EEngine.instance.setting.FramePreSecond);
        }