public Int32 AddLevel(H1Level level)
        {
            Int32 newIndex = m_Levels.Count;

            m_Levels.Add(level);

            return(newIndex);
        }
Beispiel #2
0
        public void Initialize(IntPtr windowHandle, int width, int height)
        {
            m_WindowHandle = windowHandle;

            //@TODO - re-ordering this correctly!

            // renderer
            m_Renderer = H1Global <H1ManagedRenderer> .Instance;
            m_Renderer.Initialize(width, height, windowHandle);

            // asset importer (Assimp)
            m_AssimpImporter = H1Global <H1AssimpImporter> .Instance;
            m_AssimpImporter.Initialize();

            // world system
            m_World = H1Global <H1World> .Instance;
            Int32 lvIndex = m_World.AddLevel(new H1Level());
            // set persistent level
            H1Level persistentLevel = m_World.GetLevel(lvIndex);

            m_World.PersistentLevel = persistentLevel;

            H1AssetContext AssetContext = H1Global <H1AssimpImporter> .Instance.asset;

            if (AssetContext != null)
            {
                H1ModelContext ModelContext = H1Global <H1AssimpImporter> .Instance.asset.GetModel(0);

                // create temporary actor
                H1Actor testActor = new H1Actor();
                H1StaticMeshComponent staticMeshComponent = new H1StaticMeshComponent();
                staticMeshComponent.StaticMesh = new H1StaticMesh(ModelContext);
                testActor.AddActorComponent <H1StaticMeshComponent>(staticMeshComponent);

                // create temporary skeletal mesh component
                H1SkeletalMeshComponent skeletalMeshComponent = new H1SkeletalMeshComponent();
                skeletalMeshComponent.SkeletalMesh = new H1SkeletalMesh();
                H1StaticLODModel staticLODModelRef = skeletalMeshComponent.SkeletalMesh.PrepareProcessAssetContext(ModelContext.SkeletalContexts[0]);
                skeletalMeshComponent.SkeletalMesh.ProcessAssetContext(staticLODModelRef, ModelContext.Meshes.ToArray(), ModelContext.SkeletalContexts[0]);
                skeletalMeshComponent.AnimScriptInstance.ProcessAnimationContext(ModelContext.AnimationContext);

                // generate skeletalmeshobject
                skeletalMeshComponent.GenerateSkeleltalMeshObjectGpuSkin();

                testActor.AddActorComponent <H1SkeletalMeshComponent>(skeletalMeshComponent);

                // add the actor to the world
                m_World.PersistentLevel.AddActor(testActor);

                //@TODO - temporary force to order to working
                // after load assets
                m_Renderer.LoadAssets();
            }

            // @TODO - make the global accessor to access the current running app class!
            m_WPFInputManager = H1Global <H1InputManagerWpf> .Instance;

            H1InteractionContext <Window> context = new H1InteractionContext <Window>(Application.Current.MainWindow);

            m_WPFInputManager.Initialize(context);

            // initialize the camera
            m_Camera = new H1Camera();

            // set the camera properties
            Vector3 eye         = new Vector3(0.0f, 0.0f, -10.0f);
            Vector3 lookAtPoint = new Vector3(0.0f, 0.0f, 0.0f);
            Vector3 upVector    = new Vector3(0.0f, 1.0f, 0.0f);
            float   fov         = Convert.ToSingle((Math.PI / 180.0) * 45.0);
            float   nearZ       = 1.0f;
            float   farZ        = 10000.0f;
            float   focusRadius = 1.0f;
            float   aspectRatio = m_Renderer.Width / m_Renderer.Height;

            // set the camera state
            m_Camera.SetState(H1ViewTypes.Perspective, eye, lookAtPoint, upVector, fov, aspectRatio, nearZ, farZ, focusRadius);

            // camera controller
            m_CameraController        = new H1CameraController();
            m_CameraController.Camera = m_Camera;

            m_VisualDebugger = H1Global <H1VisualDebugger> .Instance;

            // task scheduler (fiber-based) c++
            SGDManagedEngineWrapper.H1ManagedTaskSchedulerLayerWrapper.InitializeTaskScheduler();
            SGDManagedEngineWrapper.H1ManagedTaskSchedulerLayerWrapper.StartTaskScheduler();
        }